blob: 1dcd78627e34dee2144b2607ed6cc9c02abfd1c4 [file] [log] [blame]
# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# This is a BUILD.bazel file template for FreeRTOS.
#
# TODO(b/326625641): Contribute this to upstream FreeRTOS.
# buildifier: disable=module-docstring
package(default_visibility = ["//visibility:public"])
# Label flag that points to the cc_library target providing freertos_config.h.
label_flag(
name = "freertos_config",
build_setting_default = ":default_freertos_config",
)
cc_library(
name = "default_freertos_config",
# The "default" config is not compatible with any configuration: you can't
# build FreeRTOS without choosing a config.
target_compatible_with = ["@platforms//:incompatible"],
)
# Constraint setting used to select the FreeRTOSConfig version.
constraint_setting(
name = "freertos_config_setting",
)
constraint_setting(
name = "port",
)
# Cortex-M33 with No TrustZone
constraint_value(
name = "port_ARM_CM33_NTZ",
constraint_setting = ":port",
)
constraint_value(
name = "port_ARM_CM4F",
constraint_setting = ":port",
)
constraint_value(
name = "port_ARM_CM7",
constraint_setting = ":port",
)
constraint_value(
name = "port_Xtensa",
constraint_setting = ":port",
)
cc_library(
name = "freertos",
srcs = [
"croutine.c",
"event_groups.c",
"list.c",
"queue.c",
"stream_buffer.c",
"timers.c",
] + select({
":port_ARM_CM33_NTZ": [
"portable/GCC/ARM_CM33_NTZ/non_secure/port.c",
"portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c",
],
":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/port.c"],
":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/port.c"],
":port_Xtensa": [
"portable/ThirdParty/XCC/Xtensa/mpu.S",
"portable/ThirdParty/XCC/Xtensa/port.c",
"portable/ThirdParty/XCC/Xtensa/portasm.S",
"portable/ThirdParty/XCC/Xtensa/portclib.c",
"portable/ThirdParty/XCC/Xtensa/portmpu.c",
"portable/ThirdParty/XCC/Xtensa/xtensa_context.S",
"portable/ThirdParty/XCC/Xtensa/xtensa_coproc_handler.S",
"portable/ThirdParty/XCC/Xtensa/xtensa_intr.c",
"portable/ThirdParty/XCC/Xtensa/xtensa_intr_asm.S",
"portable/ThirdParty/XCC/Xtensa/xtensa_intr_wrapper.c",
"portable/ThirdParty/XCC/Xtensa/xtensa_overlay_os_hook.c",
"portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S",
],
"//conditions:default": [],
}),
includes = ["include/"],
textual_hdrs = [
"include/FreeRTOS.h",
"include/StackMacros.h",
"include/croutine.h",
"include/deprecated_definitions.h",
"include/event_groups.h",
"include/list.h",
"include/message_buffer.h",
"include/mpu_wrappers.h",
"include/portable.h",
"include/projdefs.h",
"include/queue.h",
"include/semphr.h",
"include/stack_macros.h",
"include/stream_buffer.h",
"include/task.h",
"include/timers.h",
],
deps = [
":freertos_config",
":freertos_malloc",
":freertos_port_headers",
":tasks_c",
],
# Required because breaking out tasks_c results in the dependencies between
# the libraries not being quite correct: to link tasks_c you actually need
# a bunch of the source files from here (e.g., list.c).
alwayslink = 1,
)
cc_library(
name = "freertos_port_headers",
hdrs = select({
":port_ARM_CM33_NTZ": [
"portable/GCC/ARM_CM33_NTZ/non_secure/portasm.h",
"portable/GCC/ARM_CM33_NTZ/non_secure/portmacro.h",
],
":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/portmacro.h"],
":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/portmacro.h"],
":port_Xtensa": [
"portable/ThirdParty/XCC/Xtensa/portbenchmark.h",
"portable/ThirdParty/XCC/Xtensa/portmacro.h",
"portable/ThirdParty/XCC/Xtensa/porttrace.h",
"portable/ThirdParty/XCC/Xtensa/xtensa_api.h",
"portable/ThirdParty/XCC/Xtensa/xtensa_config.h",
"portable/ThirdParty/XCC/Xtensa/xtensa_context.h",
"portable/ThirdParty/XCC/Xtensa/xtensa_rtos.h",
"portable/ThirdParty/XCC/Xtensa/xtensa_timer.h",
],
"//conditions:default": [],
}),
includes = select({
":port_ARM_CM33_NTZ": ["portable/GCC/ARM_CM33_NTZ/non_secure"],
":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/"],
":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/"],
":port_Xtensa": ["portable/ThirdParty/XCC/Xtensa"],
"//conditions:default": [],
}),
)
# Headers transitively included by using "FreeRTOS.h"
cc_library(
name = "freertos_headers",
hdrs = [
"include/FreeRTOS.h",
"include/deprecated_definitions.h",
"include/list.h",
"include/mpu_wrappers.h",
"include/portable.h",
"include/projdefs.h",
"include/stack_macros.h",
"include/task.h",
"include/timers.h",
],
includes = [
"include/",
],
visibility = ["//visibility:private"],
deps = [
":freertos_config",
":freertos_port_headers",
],
)
# Constraint setting used to determine if task statics should be disabled.
constraint_setting(
name = "disable_tasks_statics_setting",
default_constraint_value = ":no_disable_task_statics",
)
constraint_value(
name = "disable_task_statics",
constraint_setting = ":disable_tasks_statics_setting",
)
constraint_value(
name = "no_disable_task_statics",
constraint_setting = ":disable_tasks_statics_setting",
)
cc_library(
name = "tasks_c",
srcs = ["tasks.c"],
local_defines = select({
":disable_task_statics": [
"static=",
],
"//conditions:default": [],
}),
deps = [":freertos_headers"],
)
# Constraint setting for malloc implementation.
constraint_setting(
name = "malloc",
default_constraint_value = ":no_malloc",
)
constraint_value(
name = "no_malloc",
constraint_setting = ":malloc",
)
constraint_value(
name = "malloc_heap_1",
constraint_setting = ":malloc",
)
constraint_value(
name = "malloc_heap_2",
constraint_setting = ":malloc",
)
constraint_value(
name = "malloc_heap_3",
constraint_setting = ":malloc",
)
constraint_value(
name = "malloc_heap_4",
constraint_setting = ":malloc",
)
cc_library(
name = "freertos_malloc",
srcs = select({
":malloc_heap_1": ["portable/MemMang/heap_1.c"],
":malloc_heap_2": ["portable/MemMang/heap_2.c"],
":malloc_heap_3": ["portable/MemMang/heap_3.c"],
":malloc_heap_4": ["portable/MemMang/heap_4.c"],
":no_malloc": [],
}),
visibility = ["//visibility:private"],
deps = [":freertos_headers"],
)
# Exported for
# pw_thread_freertos/py/pw_thread_freertos/generate_freertos_tsktcb.py
exports_files(
["tasks.c"],
)