blob: c8cbe1ce9981327f415d2126d96c2599a2cbfc0c [file] [log] [blame]
Ewout van Bekkumf0106062021-05-06 14:08:33 -07001# Copyright 2021 The Pigweed Authors
Ewout van Bekkum58901932020-11-09 12:46:52 -08002#
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 "//pw_build:pigweed.bzl",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080017 "pw_cc_facade",
Ewout van Bekkum58901932020-11-09 12:46:52 -080018 "pw_cc_library",
19 "pw_cc_test",
20)
Ewout van Bekkumf0106062021-05-06 14:08:33 -070021load(
22 "//pw_build:selects.bzl",
23 "TARGET_COMPATIBLE_WITH_HOST_SELECT",
24)
Ewout van Bekkum58901932020-11-09 12:46:52 -080025
26package(default_visibility = ["//visibility:public"])
27
Rob Mohr5fc25412021-06-23 09:35:23 -070028licenses(["notice"])
Ewout van Bekkum58901932020-11-09 12:46:52 -080029
Nathaniel Broughc2d57812021-04-18 22:52:00 +080030pw_cc_facade(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080031 name = "binary_semaphore_facade",
32 hdrs = [
33 "public/pw_sync/binary_semaphore.h",
34 ],
35 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080036 deps = [
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080037 "//pw_chrono:system_clock",
38 "//pw_preprocessor",
39 ],
40)
41
42pw_cc_library(
43 name = "binary_semaphore",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080044 srcs = [
45 "binary_semaphore.cc",
46 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080047 deps = [
48 ":binary_semaphore_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080049 "@pigweed_config//:pw_sync_binary_semaphore_backend",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080050 ],
51)
52
53pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +080054 name = "binary_semaphore_backend_multiplexer",
55 visibility = ["@pigweed_config//:__pkg__"],
56 deps = select({
57 "@platforms//os:none": ["//pw_sync_baremetal:binary_semaphore"],
58 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:binary_semaphore"],
59 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:binary_semaphore"],
60 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:binary_semaphore"],
61 "//conditions:default": ["//pw_sync_stl:binary_semaphore"],
62 }),
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080063)
64
Nathaniel Broughc2d57812021-04-18 22:52:00 +080065pw_cc_facade(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080066 name = "counting_semaphore_facade",
67 hdrs = [
68 "public/pw_sync/counting_semaphore.h",
69 ],
70 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080071 deps = [
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080072 "//pw_chrono:system_clock",
73 "//pw_preprocessor",
74 ],
75)
76
77pw_cc_library(
78 name = "counting_semaphore",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080079 srcs = [
80 "counting_semaphore.cc",
81 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080082 deps = [
83 ":counting_semaphore_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080084 "@pigweed_config//:pw_sync_counting_semaphore_backend",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080085 ],
86)
87
88pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +080089 name = "counting_semaphore_backend_multiplexer",
90 visibility = ["@pigweed_config//:__pkg__"],
91 deps = select({
92 "@platforms//os:none": ["//pw_sync_baremetal:counting_semaphore"],
93 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:counting_semaphore"],
94 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:counting_semaphore"],
95 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:counting_semaphore"],
96 "//conditions:default": ["//pw_sync_stl:counting_semaphore"],
97 }),
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080098)
99
100pw_cc_library(
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700101 name = "lock_annotations",
102 hdrs = [
103 "public/pw_sync/lock_annotations.h",
104 ],
105 includes = ["public"],
106 deps = [
107 "//pw_preprocessor",
108 ],
109)
110
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -0700111pw_cc_library(
112 name = "borrow",
113 hdrs = [
114 "public/pw_sync/borrow.h",
115 ],
116 includes = ["public"],
117 deps = [
118 "//pw_assert",
119 ],
120)
121
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800122pw_cc_facade(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800123 name = "mutex_facade",
124 hdrs = [
125 "public/pw_sync/mutex.h",
126 ],
127 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800128 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800129 ":lock_annotations",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800130 "//pw_preprocessor",
131 ],
132)
133
134pw_cc_library(
135 name = "mutex",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800136 srcs = [
137 "mutex.cc",
138 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800139 deps = [
140 ":mutex_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800141 "@pigweed_config//:pw_sync_mutex_backend",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800142 ],
143)
144
145pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800146 name = "mutex_backend_multiplexer",
147 visibility = ["@pigweed_config//:__pkg__"],
148 deps = select({
149 "@platforms//os:none": ["//pw_sync_baremetal:mutex"],
150 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:mutex"],
151 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:mutex"],
152 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:mutex"],
153 "//conditions:default": ["//pw_sync_stl:mutex"],
154 }),
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800155)
156
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800157pw_cc_facade(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700158 name = "timed_mutex_facade",
159 hdrs = [
160 "public/pw_sync/timed_mutex.h",
161 ],
162 includes = ["public"],
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700163 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800164 ":lock_annotations",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700165 ":mutex_facade",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700166 "//pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700167 "//pw_preprocessor",
168 ],
169)
170
171pw_cc_library(
172 name = "timed_mutex",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800173 srcs = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800174 "timed_mutex.cc",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800175 ],
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800176 deps = [
177 ":mutex",
178 ":timed_mutex_facade",
179 "@pigweed_config//:pw_sync_timed_mutex_backend",
180 ],
181)
182
183pw_cc_library(
184 name = "timed_mutex_backend_multiplexer",
185 visibility = ["@pigweed_config//:__pkg__"],
186 deps = select({
187 "@platforms//os:none": ["//pw_sync_baremetal:timed_mutex"],
188 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:timed_mutex"],
189 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:timed_mutex"],
190 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:timed_mutex"],
191 "//conditions:default": ["//pw_sync_stl:timed_mutex"],
192 }),
193)
194
195pw_cc_facade(
196 name = "interrupt_spin_lock_facade",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800197 hdrs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800198 "public/pw_sync/interrupt_spin_lock.h",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800199 ],
200 includes = ["public"],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800201 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800202 ":lock_annotations",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800203 "//pw_preprocessor",
204 ],
205)
206
207pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800208 name = "interrupt_spin_lock",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800209 srcs = [
210 "interrupt_spin_lock.cc",
211 ],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800212 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800213 ":interrupt_spin_lock_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800214 "@pigweed_config//:pw_sync_interrupt_spin_lock_backend",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800215 ],
216)
217
218pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800219 name = "interrupt_spin_lock_backend_multiplexer",
220 visibility = ["@pigweed_config//:__pkg__"],
221 deps = select({
222 "@platforms//os:none": ["//pw_sync_baremetal:interrupt_spin_lock"],
223 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:interrupt_spin_lock"],
224 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:interrupt_spin_lock"],
225 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:interrupt_spin_lock"],
226 "//conditions:default": ["//pw_sync_stl:interrupt_spin_lock"],
227 }),
Ewout van Bekkum58901932020-11-09 12:46:52 -0800228)
229
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700230pw_cc_facade(
231 name = "thread_notification_facade",
232 hdrs = [
233 "public/pw_sync/thread_notification.h",
234 ],
235 includes = ["public"],
236)
237
238pw_cc_library(
239 name = "thread_notification",
240 deps = [
241 ":thread_notification_facade",
242 "@pigweed_config//:pw_sync_thread_notification_backend",
243 ],
244)
245
246pw_cc_library(
247 name = "thread_notification_backend_multiplexer",
248 visibility = ["@pigweed_config//:__pkg__"],
249 deps = select({
250 "//conditions:default": ["//pw_sync:binary_semaphore_thread_notification_backend"],
251 }),
252)
253
254pw_cc_facade(
255 name = "timed_thread_notification_facade",
256 hdrs = [
257 "public/pw_sync/timed_thread_notification.h",
258 ],
259 includes = ["public"],
260 deps = [
261 ":thread_notification_facade",
262 "//pw_chrono:system_clock",
263 ],
264)
265
266pw_cc_library(
267 name = "timed_thread_notification",
268 deps = [
269 ":thread_notification",
270 ":timed_thread_notification_facade",
271 "@pigweed_config//:pw_sync_timed_thread_notification_backend",
272 ],
273)
274
275pw_cc_library(
276 name = "timed_thread_notification_backend_multiplexer",
277 visibility = ["@pigweed_config//:__pkg__"],
278 deps = select({
279 "//conditions:default": ["//pw_sync:binary_semaphore_timed_thread_notification_backend"],
280 }),
281)
282
283pw_cc_library(
284 name = "binary_semaphore_thread_notification_backend_headers",
285 hdrs = [
286 "public/pw_sync/backends/binary_semaphore_thread_notification_inline.h",
287 "public/pw_sync/backends/binary_semaphore_thread_notification_native.h",
288 "public_overrides/pw_sync_backend/thread_notification_inline.h",
289 "public_overrides/pw_sync_backend/thread_notification_native.h",
290 ],
291 includes = [
292 "public",
293 "public_overrides",
294 ],
Rob Mohr9c266ab2021-06-14 17:48:49 -0700295 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700296 deps = [
297 ":binary_semaphore_headers",
298 ],
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700299)
300
301pw_cc_library(
302 name = "binary_semaphore_thread_notification_backend",
303 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
304 deps = [
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700305 ":binary_semaphore_facade",
Rob Mohr9c266ab2021-06-14 17:48:49 -0700306 ":binary_semaphore_thread_notification_headers",
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700307 ":thread_notification_facade",
308 ],
309)
310
311pw_cc_library(
312 name = "binary_semaphore_timed_thread_notification_backend_headers",
313 hdrs = [
314 "public/pw_sync/backends/binary_semaphore_timed_thread_notification_inline.h",
315 "public_overrides/pw_sync_backend/timed_thread_notification_inline.h",
316 ],
317 includes = [
318 "public",
319 "public_overrides",
320 ],
321 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
322 deps = [
323 ":binary_semaphore_thread_notification_backend_headers",
324 "//pw_chrono:system_clock",
325 ],
326)
327
328pw_cc_library(
329 name = "binary_semaphore_timed_thread_notification_backend",
330 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
331 deps = [
332 ":binary_semaphore_thread_notification_backend",
333 ":binary_semaphore_timed_thread_notification_backend_headers",
334 "//pw_sync:timed_thread_notification_facade",
335 ],
336)
337
Ewout van Bekkum58901932020-11-09 12:46:52 -0800338pw_cc_library(
339 name = "yield_core",
340 hdrs = [
341 "public/pw_sync/yield_core.h",
342 ],
343 includes = ["public"],
344)
345
346pw_cc_test(
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -0700347 name = "borrow_test",
348 srcs = [
349 "borrow_test.cc",
350 ],
351 deps = [
352 ":borrow",
353 "//pw_assert",
354 "//pw_unit_test",
355 ],
356)
357
358pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800359 name = "binary_semaphore_facade_test",
360 srcs = [
361 "binary_semaphore_facade_test.cc",
362 "binary_semaphore_facade_test_c.c",
363 ],
364 deps = [
365 ":binary_semaphore",
366 "//pw_preprocessor",
367 "//pw_unit_test",
368 ],
369)
370
371pw_cc_test(
372 name = "counting_semaphore_facade_test",
373 srcs = [
374 "counting_semaphore_facade_test.cc",
375 "counting_semaphore_facade_test_c.c",
376 ],
377 deps = [
378 ":counting_semaphore",
379 "//pw_preprocessor",
380 "//pw_unit_test",
381 ],
382)
383
384pw_cc_test(
385 name = "mutex_facade_test",
386 srcs = [
387 "mutex_facade_test.cc",
388 "mutex_facade_test_c.c",
389 ],
390 deps = [
391 ":mutex",
392 "//pw_preprocessor",
393 "//pw_unit_test",
394 ],
395)
396
397pw_cc_test(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700398 name = "timed_mutex_facade_test",
399 srcs = [
400 "timed_mutex_facade_test.cc",
401 "timed_mutex_facade_test_c.c",
402 ],
403 deps = [
404 ":timed_mutex",
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700405 "//pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700406 "//pw_preprocessor",
407 "//pw_unit_test",
408 ],
409)
410
411pw_cc_test(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800412 name = "interrupt_spin_lock_facade_test",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800413 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800414 "interrupt_spin_lock_facade_test.cc",
415 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800416 ],
417 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800418 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800419 "//pw_preprocessor",
420 "//pw_unit_test",
421 ],
422)
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700423
424pw_cc_test(
425 name = "thread_notification_facade_test",
426 srcs = [
427 "thread_notification_facade_test.cc",
428 "thread_notification_facade_test_c.c",
429 ],
430 deps = [
431 ":thread_notification",
432 "//pw_unit_test",
433 ],
434)
435
436pw_cc_test(
437 name = "timed_thread_notification_facade_test",
438 srcs = [
439 "timed_thread_notification_facade_test.cc",
440 "timed_thread_notification_facade_test_c.c",
441 ],
442 deps = [
443 ":timed_thread_notification",
444 "//pw_chrono:system_clock",
445 "//pw_unit_test",
446 ],
447)