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