blob: a5752996b0228a739da688bac21194ddc0853d84 [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
28licenses(["notice"]) # Apache License 2.0
29
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
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800111pw_cc_facade(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800112 name = "mutex_facade",
113 hdrs = [
114 "public/pw_sync/mutex.h",
115 ],
116 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800117 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800118 ":lock_annotations",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800119 "//pw_preprocessor",
120 ],
121)
122
123pw_cc_library(
124 name = "mutex",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800125 srcs = [
126 "mutex.cc",
127 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800128 deps = [
129 ":mutex_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800130 "@pigweed_config//:pw_sync_mutex_backend",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800131 ],
132)
133
134pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800135 name = "mutex_backend_multiplexer",
136 visibility = ["@pigweed_config//:__pkg__"],
137 deps = select({
138 "@platforms//os:none": ["//pw_sync_baremetal:mutex"],
139 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:mutex"],
140 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:mutex"],
141 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:mutex"],
142 "//conditions:default": ["//pw_sync_stl:mutex"],
143 }),
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800144)
145
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800146pw_cc_facade(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700147 name = "timed_mutex_facade",
148 hdrs = [
149 "public/pw_sync/timed_mutex.h",
150 ],
151 includes = ["public"],
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700152 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800153 ":lock_annotations",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700154 ":mutex_facade",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700155 "//pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700156 "//pw_preprocessor",
157 ],
158)
159
160pw_cc_library(
161 name = "timed_mutex",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800162 srcs = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800163 "timed_mutex.cc",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800164 ],
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800165 deps = [
166 ":mutex",
167 ":timed_mutex_facade",
168 "@pigweed_config//:pw_sync_timed_mutex_backend",
169 ],
170)
171
172pw_cc_library(
173 name = "timed_mutex_backend_multiplexer",
174 visibility = ["@pigweed_config//:__pkg__"],
175 deps = select({
176 "@platforms//os:none": ["//pw_sync_baremetal:timed_mutex"],
177 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:timed_mutex"],
178 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:timed_mutex"],
179 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:timed_mutex"],
180 "//conditions:default": ["//pw_sync_stl:timed_mutex"],
181 }),
182)
183
184pw_cc_facade(
185 name = "interrupt_spin_lock_facade",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800186 hdrs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800187 "public/pw_sync/interrupt_spin_lock.h",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800188 ],
189 includes = ["public"],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800190 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800191 ":lock_annotations",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800192 "//pw_preprocessor",
193 ],
194)
195
196pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800197 name = "interrupt_spin_lock",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800198 srcs = [
199 "interrupt_spin_lock.cc",
200 ],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800201 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800202 ":interrupt_spin_lock_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800203 "@pigweed_config//:pw_sync_interrupt_spin_lock_backend",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800204 ],
205)
206
207pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800208 name = "interrupt_spin_lock_backend_multiplexer",
209 visibility = ["@pigweed_config//:__pkg__"],
210 deps = select({
211 "@platforms//os:none": ["//pw_sync_baremetal:interrupt_spin_lock"],
212 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:interrupt_spin_lock"],
213 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:interrupt_spin_lock"],
214 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:interrupt_spin_lock"],
215 "//conditions:default": ["//pw_sync_stl:interrupt_spin_lock"],
216 }),
Ewout van Bekkum58901932020-11-09 12:46:52 -0800217)
218
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700219pw_cc_facade(
220 name = "thread_notification_facade",
221 hdrs = [
222 "public/pw_sync/thread_notification.h",
223 ],
224 includes = ["public"],
225)
226
227pw_cc_library(
228 name = "thread_notification",
229 deps = [
230 ":thread_notification_facade",
231 "@pigweed_config//:pw_sync_thread_notification_backend",
232 ],
233)
234
235pw_cc_library(
236 name = "thread_notification_backend_multiplexer",
237 visibility = ["@pigweed_config//:__pkg__"],
238 deps = select({
239 "//conditions:default": ["//pw_sync:binary_semaphore_thread_notification_backend"],
240 }),
241)
242
243pw_cc_facade(
244 name = "timed_thread_notification_facade",
245 hdrs = [
246 "public/pw_sync/timed_thread_notification.h",
247 ],
248 includes = ["public"],
249 deps = [
250 ":thread_notification_facade",
251 "//pw_chrono:system_clock",
252 ],
253)
254
255pw_cc_library(
256 name = "timed_thread_notification",
257 deps = [
258 ":thread_notification",
259 ":timed_thread_notification_facade",
260 "@pigweed_config//:pw_sync_timed_thread_notification_backend",
261 ],
262)
263
264pw_cc_library(
265 name = "timed_thread_notification_backend_multiplexer",
266 visibility = ["@pigweed_config//:__pkg__"],
267 deps = select({
268 "//conditions:default": ["//pw_sync:binary_semaphore_timed_thread_notification_backend"],
269 }),
270)
271
272pw_cc_library(
273 name = "binary_semaphore_thread_notification_backend_headers",
274 hdrs = [
275 "public/pw_sync/backends/binary_semaphore_thread_notification_inline.h",
276 "public/pw_sync/backends/binary_semaphore_thread_notification_native.h",
277 "public_overrides/pw_sync_backend/thread_notification_inline.h",
278 "public_overrides/pw_sync_backend/thread_notification_native.h",
279 ],
280 includes = [
281 "public",
282 "public_overrides",
283 ],
Rob Mohr9c266ab2021-06-14 17:48:49 -0700284 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700285 deps = [
286 ":binary_semaphore_headers",
287 ],
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700288)
289
290pw_cc_library(
291 name = "binary_semaphore_thread_notification_backend",
292 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
293 deps = [
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700294 ":binary_semaphore_facade",
Rob Mohr9c266ab2021-06-14 17:48:49 -0700295 ":binary_semaphore_thread_notification_headers",
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700296 ":thread_notification_facade",
297 ],
298)
299
300pw_cc_library(
301 name = "binary_semaphore_timed_thread_notification_backend_headers",
302 hdrs = [
303 "public/pw_sync/backends/binary_semaphore_timed_thread_notification_inline.h",
304 "public_overrides/pw_sync_backend/timed_thread_notification_inline.h",
305 ],
306 includes = [
307 "public",
308 "public_overrides",
309 ],
310 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
311 deps = [
312 ":binary_semaphore_thread_notification_backend_headers",
313 "//pw_chrono:system_clock",
314 ],
315)
316
317pw_cc_library(
318 name = "binary_semaphore_timed_thread_notification_backend",
319 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
320 deps = [
321 ":binary_semaphore_thread_notification_backend",
322 ":binary_semaphore_timed_thread_notification_backend_headers",
323 "//pw_sync:timed_thread_notification_facade",
324 ],
325)
326
Ewout van Bekkum58901932020-11-09 12:46:52 -0800327pw_cc_library(
328 name = "yield_core",
329 hdrs = [
330 "public/pw_sync/yield_core.h",
331 ],
332 includes = ["public"],
333)
334
335pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800336 name = "binary_semaphore_facade_test",
337 srcs = [
338 "binary_semaphore_facade_test.cc",
339 "binary_semaphore_facade_test_c.c",
340 ],
341 deps = [
342 ":binary_semaphore",
343 "//pw_preprocessor",
344 "//pw_unit_test",
345 ],
346)
347
348pw_cc_test(
349 name = "counting_semaphore_facade_test",
350 srcs = [
351 "counting_semaphore_facade_test.cc",
352 "counting_semaphore_facade_test_c.c",
353 ],
354 deps = [
355 ":counting_semaphore",
356 "//pw_preprocessor",
357 "//pw_unit_test",
358 ],
359)
360
361pw_cc_test(
362 name = "mutex_facade_test",
363 srcs = [
364 "mutex_facade_test.cc",
365 "mutex_facade_test_c.c",
366 ],
367 deps = [
368 ":mutex",
369 "//pw_preprocessor",
370 "//pw_unit_test",
371 ],
372)
373
374pw_cc_test(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700375 name = "timed_mutex_facade_test",
376 srcs = [
377 "timed_mutex_facade_test.cc",
378 "timed_mutex_facade_test_c.c",
379 ],
380 deps = [
381 ":timed_mutex",
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700382 "//pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700383 "//pw_preprocessor",
384 "//pw_unit_test",
385 ],
386)
387
388pw_cc_test(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800389 name = "interrupt_spin_lock_facade_test",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800390 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800391 "interrupt_spin_lock_facade_test.cc",
392 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800393 ],
394 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800395 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800396 "//pw_preprocessor",
397 "//pw_unit_test",
398 ],
399)
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700400
401pw_cc_test(
402 name = "thread_notification_facade_test",
403 srcs = [
404 "thread_notification_facade_test.cc",
405 "thread_notification_facade_test_c.c",
406 ],
407 deps = [
408 ":thread_notification",
409 "//pw_unit_test",
410 ],
411)
412
413pw_cc_test(
414 name = "timed_thread_notification_facade_test",
415 srcs = [
416 "timed_thread_notification_facade_test.cc",
417 "timed_thread_notification_facade_test_c.c",
418 ],
419 deps = [
420 ":timed_thread_notification",
421 "//pw_chrono:system_clock",
422 "//pw_unit_test",
423 ],
424)