1# Copyright 2021 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load( 16 "@pigweed//pw_build:pigweed.bzl", 17 "pw_cc_library", 18) 19 20package(default_visibility = ["//visibility:public"]) 21 22licenses(["notice"]) 23 24pw_cc_library( 25 name = "config_assert", 26 hdrs = [ 27 "public/pw_third_party/freertos/config_assert.h", 28 ], 29 includes = ["public"], 30 deps = [ 31 "@pigweed//pw_assert", 32 ], 33) 34 35constraint_setting( 36 name = "port", 37) 38 39constraint_value( 40 name = "port_ARM_CM7", 41 constraint_setting = ":port", 42) 43 44constraint_value( 45 name = "port_ARM_CM4F", 46 constraint_setting = ":port", 47) 48 49pw_cc_library( 50 name = "freertos", 51 srcs = [ 52 "croutine.c", 53 "event_groups.c", 54 "list.c", 55 "queue.c", 56 "stream_buffer.c", 57 "timers.c", 58 ] + select({ 59 ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/port.c"], 60 ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/port.c"], 61 "//conditions:default": [], 62 }), 63 includes = ["include/"] + select({ 64 ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F"], 65 ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1"], 66 "//conditions:default": [], 67 }), 68 textual_hdrs = [ 69 "include/FreeRTOS.h", 70 "include/StackMacros.h", 71 "include/croutine.h", 72 "include/deprecated_definitions.h", 73 "include/event_groups.h", 74 "include/list.h", 75 "include/message_buffer.h", 76 "include/mpu_wrappers.h", 77 "include/portable.h", 78 "include/projdefs.h", 79 "include/queue.h", 80 "include/semphr.h", 81 "include/stack_macros.h", 82 "include/stream_buffer.h", 83 "include/task.h", 84 "include/timers.h", 85 ] + select({ 86 ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/portmacro.h"], 87 ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/portmacro.h"], 88 "//conditions:default": [], 89 }), 90 deps = [ 91 ":pigweed_tasks_c", 92 "@pigweed_config//:freertos_config", 93 ], 94 # Required because breaking out tasks_c results in the dependencies between 95 # the libraries not being quite correct: to link pigweed_tasks_c you 96 # actually need a bunch of the source files from here (e.g., list.c). 97 alwayslink = 1, 98) 99 100# Constraint setting used to determine if task statics should be disabled. 101constraint_setting( 102 name = "disable_tasks_statics_setting", 103 default_constraint_value = ":no_disable_task_statics", 104) 105 106constraint_value( 107 name = "disable_task_statics", 108 constraint_setting = ":disable_tasks_statics_setting", 109) 110 111constraint_value( 112 name = "no_disable_task_statics", 113 constraint_setting = ":disable_tasks_statics_setting", 114) 115 116pw_cc_library( 117 name = "pigweed_tasks_c", 118 srcs = ["tasks.c"], 119 defines = select({ 120 ":disable_task_statics": [ 121 "PW_THIRD_PARTY_FREERTOS_NO_STATICS=1", 122 ], 123 "//conditions:default": [], 124 }), 125 includes = [ 126 "include/", 127 ] + select({ 128 ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/"], 129 ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/"], 130 "//conditions:default": [], 131 }), 132 local_defines = select({ 133 ":disable_task_statics": [ 134 "static=", 135 ], 136 "//conditions:default": [], 137 }), 138 # tasks.c transitively includes all these headers :/ 139 textual_hdrs = [ 140 "include/FreeRTOS.h", 141 "include/portable.h", 142 "include/projdefs.h", 143 "include/list.h", 144 "include/deprecated_definitions.h", 145 "include/mpu_wrappers.h", 146 "include/stack_macros.h", 147 "include/task.h", 148 "include/timers.h", 149 ] + select({ 150 ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/portmacro.h"], 151 ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/portmacro.h"], 152 "//conditions:default": [], 153 }), 154 deps = ["@pigweed_config//:freertos_config"], 155) 156 157# Constraint setting used to select the FreeRTOSConfig version. 158constraint_setting( 159 name = "freertos_config_setting", 160) 161 162alias( 163 name = "freertos_config", 164 actual = select({ 165 "@pigweed//targets/stm32f429i_disc1_stm32cube:freertos_config_cv": "@pigweed//targets/stm32f429i_disc1_stm32cube:freertos_config", 166 "//conditions:default": "default_freertos_config", 167 }), 168) 169 170pw_cc_library( 171 name = "default_freertos_config", 172 # The "default" config is not compatible with any configuration: you can't 173 # build FreeRTOS without choosing a config. 174 target_compatible_with = ["@platforms//:incompatible"], 175) 176 177# Exported for 178# pw_thread_freertos/py/pw_thread_freertos/generate_freertos_tsktcb.py 179exports_files( 180 ["tasks.c"], 181) 182