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