1# Copyright 2020 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 15package(default_visibility = ["//visibility:public"]) 16 17licenses(["notice"]) 18 19cc_library( 20 name = "binary_semaphore", 21 srcs = [ 22 "binary_semaphore.cc", 23 ], 24 hdrs = [ 25 "public/pw_sync_freertos/binary_semaphore_inline.h", 26 "public/pw_sync_freertos/binary_semaphore_native.h", 27 "public_overrides/pw_sync_backend/binary_semaphore_inline.h", 28 "public_overrides/pw_sync_backend/binary_semaphore_native.h", 29 ], 30 includes = [ 31 "public", 32 "public_overrides", 33 ], 34 target_compatible_with = [ 35 "//pw_build/constraints/rtos:freertos", 36 ], 37 deps = [ 38 "//pw_assert", 39 "//pw_chrono:system_clock", 40 "//pw_interrupt:context", 41 "//pw_sync:binary_semaphore.facade", 42 "@freertos", 43 ], 44) 45 46cc_library( 47 name = "counting_semaphore", 48 srcs = [ 49 "counting_semaphore.cc", 50 ], 51 hdrs = [ 52 "public/pw_sync_freertos/counting_semaphore_inline.h", 53 "public/pw_sync_freertos/counting_semaphore_native.h", 54 "public_overrides/pw_sync_backend/counting_semaphore_inline.h", 55 "public_overrides/pw_sync_backend/counting_semaphore_native.h", 56 ], 57 includes = [ 58 "public", 59 "public_overrides", 60 ], 61 target_compatible_with = select({ 62 # Not compatible with this FreeRTOS config, because it does not enable 63 # FreeRTOS counting semaphores. We mark it explicitly incompatible to 64 # that this library is skipped when you 65 # `bazel build //pw_sync_freertos/...` for a platform using that 66 # config. 67 "//targets/stm32f429i_disc1_stm32cube:freertos_config_cv": ["@platforms//:incompatible"], 68 "//conditions:default": [ 69 "//pw_build/constraints/rtos:freertos", 70 ], 71 }), 72 deps = [ 73 "//pw_assert", 74 "//pw_chrono:system_clock", 75 "//pw_interrupt:context", 76 "//pw_sync:counting_semaphore.facade", 77 "@freertos", 78 ], 79) 80 81cc_library( 82 name = "mutex", 83 hdrs = [ 84 "public/pw_sync_freertos/mutex_inline.h", 85 "public/pw_sync_freertos/mutex_native.h", 86 "public_overrides/pw_sync_backend/mutex_inline.h", 87 "public_overrides/pw_sync_backend/mutex_native.h", 88 ], 89 includes = [ 90 "public", 91 "public_overrides", 92 ], 93 target_compatible_with = [ 94 "//pw_build/constraints/rtos:freertos", 95 ], 96 deps = [ 97 "//pw_assert", 98 "//pw_interrupt:context", 99 "//pw_sync:mutex.facade", 100 "@freertos", 101 ], 102) 103 104cc_library( 105 name = "thread_notification", 106 srcs = [ 107 "thread_notification.cc", 108 ], 109 hdrs = [ 110 "public/pw_sync_freertos/config.h", 111 "public/pw_sync_freertos/thread_notification_inline.h", 112 "public/pw_sync_freertos/thread_notification_native.h", 113 "public_overrides/thread_notification/pw_sync_backend/thread_notification_inline.h", 114 "public_overrides/thread_notification/pw_sync_backend/thread_notification_native.h", 115 ], 116 includes = [ 117 "public", 118 "public_overrides/thread_notification", 119 ], 120 target_compatible_with = [ 121 "//pw_build/constraints/rtos:freertos", 122 ], 123 deps = [ 124 ":config_override", 125 "//pw_assert", 126 "//pw_interrupt:context", 127 "//pw_polyfill", 128 "//pw_sync:interrupt_spin_lock", 129 "//pw_sync:lock_annotations", 130 "//pw_sync:thread_notification.facade", 131 "@freertos", 132 ], 133) 134 135label_flag( 136 name = "config_override", 137 build_setting_default = "//pw_build:default_module_config", 138) 139 140cc_library( 141 name = "timed_thread_notification", 142 srcs = [ 143 "timed_thread_notification.cc", 144 ], 145 hdrs = [ 146 "public/pw_sync_freertos/timed_thread_notification_inline.h", 147 "public_overrides/timed_thread_notification/pw_sync_backend/timed_thread_notification_inline.h", 148 ], 149 includes = [ 150 "public", 151 "public_overrides/timed_thread_notification", 152 ], 153 target_compatible_with = [ 154 "//pw_build/constraints/rtos:freertos", 155 ], 156 deps = [ 157 "//pw_assert", 158 "//pw_chrono:system_clock", 159 "//pw_interrupt:context", 160 "//pw_sync:timed_thread_notification.facade", 161 "@freertos", 162 ], 163) 164 165cc_library( 166 name = "timed_mutex", 167 srcs = [ 168 "timed_mutex.cc", 169 ], 170 hdrs = [ 171 "public/pw_sync_freertos/timed_mutex_inline.h", 172 "public_overrides/pw_sync_backend/timed_mutex_inline.h", 173 ], 174 includes = [ 175 "public", 176 "public_overrides", 177 ], 178 target_compatible_with = [ 179 "//pw_build/constraints/rtos:freertos", 180 ], 181 deps = [ 182 "//pw_assert", 183 "//pw_chrono:system_clock", 184 "//pw_interrupt:context", 185 "//pw_sync:mutex", 186 "//pw_sync:timed_mutex.facade", 187 "@freertos", 188 ], 189) 190 191cc_library( 192 name = "interrupt_spin_lock", 193 srcs = [ 194 "interrupt_spin_lock.cc", 195 ], 196 hdrs = [ 197 "public/pw_sync_freertos/interrupt_spin_lock_inline.h", 198 "public/pw_sync_freertos/interrupt_spin_lock_native.h", 199 "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h", 200 "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h", 201 ], 202 includes = [ 203 "public", 204 "public_overrides", 205 ], 206 target_compatible_with = [ 207 "//pw_build/constraints/rtos:freertos", 208 ], 209 deps = [ 210 "//pw_assert", 211 "//pw_interrupt:context", 212 "//pw_sync:interrupt_spin_lock.facade", 213 "@freertos", 214 ], 215) 216 217# TODO: b/228998350 - Figure out how to conditionally enable this test like GN 218# 219# You can instantiate this with your own implementation of 220# "//pw_thread:non_portable_test_thread_options", see 221# ":thread_notification_test_with_static_threads" below as an example. 222# pw_cc_library( 223# name = "thread_notification_test", 224# srcs = [ 225# "thread_notification_test.cc", 226# ], 227# target_compatible_with = [ 228# "//pw_build/constraints/rtos:freertos", 229# ], 230# # TODO: b/234876414 - This should depend on FreeRTOS but our third parties 231# # currently do not have Bazel support. 232# deps = [ 233# "//pw_chrono:system_clock", 234# "//pw_sync:thread_notification", 235# "//pw_thread:sleep", 236# "//pw_thread:non_portable_test_thread_options", 237# "//pw_thread:thread", 238# "//pw_unit_test", 239# ], 240# ) 241# This is only used for the python tests. 242filegroup( 243 name = "thread_notification_test", 244 srcs = [ 245 "thread_notification_test.cc", 246 ], 247) 248 249# TODO: b/228998350 - Figure out how to conditionally enable this test like GN 250# with: 251# enable_if = pw_sync_THREAD_NOTIFICATION_BACKEND == 252# "$dir_pw_sync_freertos:thread_notification" && 253# pw_chrono_SYSTEM_CLOCK_BACKEND != "" && 254# pw_thread_THREAD_BACKEND != "" && pw_thread_SLEEP_BACKEND != "" 255# 256# pw_cc_test( 257# name = "thread_notification_test_with_static_threads", 258# target_compatible_with = [ 259# "//pw_build/constraints/rtos:freertos", 260# ], 261# deps = [ 262# ":thread_notification_test", 263# "//pw_thread_freertos:static_test_threads", 264# ], 265# ) 266 267# TODO: b/228998350 - Figure out how to conditionally enable this test like GN 268# 269# You can instantiate this with your own implementation of 270# "//pw_thread:non_portable_test_thread_options", see 271# ":timed_thread_notification_test_with_static_threads" below as an example. 272#pw_cc_library( 273# name = "timed_thread_notification_test", 274# srcs = [ 275# "timed_thread_notification_test.cc", 276# ], 277# # TODO: b/234876414 - This should depend on FreeRTOS but our third parties 278# # currently do not have Bazel support. 279# deps = [ 280# "//pw_chrono:system_clock", 281# "//pw_sync:timed_thread_notification", 282# "//pw_thread:sleep", 283# "//pw_thread:non_portable_test_thread_options", 284# "//pw_thread:thread", 285# "//pw_unit_test", 286# ], 287#) 288filegroup( 289 name = "timed_thread_notification_test", 290 srcs = [ 291 "timed_thread_notification_test.cc", 292 ], 293) 294 295# TODO: b/228998350 - Figure out how to conditionally enable this test like GN 296# with: 297# enable_if = pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND == 298# "$dir_pw_sync_freertos:timed_thread_notification" && 299# pw_chrono_SYSTEM_CLOCK_BACKEND != "" && 300# pw_thread_THREAD_BACKEND != "" && pw_thread_SLEEP_BACKEND != "" 301# 302# pw_cc_test( 303# name = "timed_thread_notification_test_with_static_threads", 304# target_compatible_with = [ 305# "//pw_build/constraints/rtos:freertos", 306# ], 307# deps = [ 308# ":timed_thread_notification_test", 309# "//pw_thread_freertos:static_test_threads", 310# ], 311# ) 312