blob: 6b63e1f741850bb8aecfa5b0b121f820dac570d6 [file] [log] [blame]
Ewout van Bekkum58901932020-11-09 12:46:52 -08001# 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",
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)
21
22package(default_visibility = ["//visibility:public"])
23
24licenses(["notice"]) # Apache License 2.0
25
Nathaniel Broughc2d57812021-04-18 22:52:00 +080026pw_cc_facade(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080027 name = "binary_semaphore_facade",
28 hdrs = [
29 "public/pw_sync/binary_semaphore.h",
30 ],
31 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080032 deps = [
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080033 "//pw_chrono:system_clock",
34 "//pw_preprocessor",
35 ],
36)
37
38pw_cc_library(
39 name = "binary_semaphore",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080040 srcs = [
41 "binary_semaphore.cc",
42 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080043 deps = [
44 ":binary_semaphore_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080045 "@pigweed_config//:pw_sync_binary_semaphore_backend",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080046 ],
47)
48
49pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +080050 name = "binary_semaphore_backend_multiplexer",
51 visibility = ["@pigweed_config//:__pkg__"],
52 deps = select({
53 "@platforms//os:none": ["//pw_sync_baremetal:binary_semaphore"],
54 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:binary_semaphore"],
55 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:binary_semaphore"],
56 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:binary_semaphore"],
57 "//conditions:default": ["//pw_sync_stl:binary_semaphore"],
58 }),
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080059)
60
Nathaniel Broughc2d57812021-04-18 22:52:00 +080061pw_cc_facade(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080062 name = "counting_semaphore_facade",
63 hdrs = [
64 "public/pw_sync/counting_semaphore.h",
65 ],
66 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080067 deps = [
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080068 "//pw_chrono:system_clock",
69 "//pw_preprocessor",
70 ],
71)
72
73pw_cc_library(
74 name = "counting_semaphore",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080075 srcs = [
76 "counting_semaphore.cc",
77 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080078 deps = [
79 ":counting_semaphore_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080080 "@pigweed_config//:pw_sync_counting_semaphore_backend",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080081 ],
82)
83
84pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +080085 name = "counting_semaphore_backend_multiplexer",
86 visibility = ["@pigweed_config//:__pkg__"],
87 deps = select({
88 "@platforms//os:none": ["//pw_sync_baremetal:counting_semaphore"],
89 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:counting_semaphore"],
90 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:counting_semaphore"],
91 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:counting_semaphore"],
92 "//conditions:default": ["//pw_sync_stl:counting_semaphore"],
93 }),
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080094)
95
96pw_cc_library(
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -070097 name = "lock_annotations",
98 hdrs = [
99 "public/pw_sync/lock_annotations.h",
100 ],
101 includes = ["public"],
102 deps = [
103 "//pw_preprocessor",
104 ],
105)
106
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800107pw_cc_facade(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800108 name = "mutex_facade",
109 hdrs = [
110 "public/pw_sync/mutex.h",
111 ],
112 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800113 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800114 ":lock_annotations",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800115 "//pw_preprocessor",
116 ],
117)
118
119pw_cc_library(
120 name = "mutex",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800121 srcs = [
122 "mutex.cc",
123 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800124 deps = [
125 ":mutex_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800126 "@pigweed_config//:pw_sync_mutex_backend",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800127 ],
128)
129
130pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800131 name = "mutex_backend_multiplexer",
132 visibility = ["@pigweed_config//:__pkg__"],
133 deps = select({
134 "@platforms//os:none": ["//pw_sync_baremetal:mutex"],
135 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:mutex"],
136 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:mutex"],
137 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:mutex"],
138 "//conditions:default": ["//pw_sync_stl:mutex"],
139 }),
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800140)
141
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800142pw_cc_facade(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700143 name = "timed_mutex_facade",
144 hdrs = [
145 "public/pw_sync/timed_mutex.h",
146 ],
147 includes = ["public"],
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700148 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800149 ":lock_annotations",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700150 ":mutex_facade",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700151 "//pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700152 "//pw_preprocessor",
153 ],
154)
155
156pw_cc_library(
157 name = "timed_mutex",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800158 srcs = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800159 "timed_mutex.cc",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800160 ],
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800161 deps = [
162 ":mutex",
163 ":timed_mutex_facade",
164 "@pigweed_config//:pw_sync_timed_mutex_backend",
165 ],
166)
167
168pw_cc_library(
169 name = "timed_mutex_backend_multiplexer",
170 visibility = ["@pigweed_config//:__pkg__"],
171 deps = select({
172 "@platforms//os:none": ["//pw_sync_baremetal:timed_mutex"],
173 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:timed_mutex"],
174 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:timed_mutex"],
175 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:timed_mutex"],
176 "//conditions:default": ["//pw_sync_stl:timed_mutex"],
177 }),
178)
179
180pw_cc_facade(
181 name = "interrupt_spin_lock_facade",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800182 hdrs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800183 "public/pw_sync/interrupt_spin_lock.h",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800184 ],
185 includes = ["public"],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800186 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800187 ":lock_annotations",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800188 "//pw_preprocessor",
189 ],
190)
191
192pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800193 name = "interrupt_spin_lock",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800194 srcs = [
195 "interrupt_spin_lock.cc",
196 ],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800197 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800198 ":interrupt_spin_lock_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800199 "@pigweed_config//:pw_sync_interrupt_spin_lock_backend",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800200 ],
201)
202
203pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800204 name = "interrupt_spin_lock_backend_multiplexer",
205 visibility = ["@pigweed_config//:__pkg__"],
206 deps = select({
207 "@platforms//os:none": ["//pw_sync_baremetal:interrupt_spin_lock"],
208 "//pw_build/constraints/rtos:embos": ["//pw_sync_embos:interrupt_spin_lock"],
209 "//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:interrupt_spin_lock"],
210 "//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:interrupt_spin_lock"],
211 "//conditions:default": ["//pw_sync_stl:interrupt_spin_lock"],
212 }),
Ewout van Bekkum58901932020-11-09 12:46:52 -0800213)
214
215pw_cc_library(
216 name = "yield_core",
217 hdrs = [
218 "public/pw_sync/yield_core.h",
219 ],
220 includes = ["public"],
221)
222
223pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800224 name = "binary_semaphore_facade_test",
225 srcs = [
226 "binary_semaphore_facade_test.cc",
227 "binary_semaphore_facade_test_c.c",
228 ],
229 deps = [
230 ":binary_semaphore",
231 "//pw_preprocessor",
232 "//pw_unit_test",
233 ],
234)
235
236pw_cc_test(
237 name = "counting_semaphore_facade_test",
238 srcs = [
239 "counting_semaphore_facade_test.cc",
240 "counting_semaphore_facade_test_c.c",
241 ],
242 deps = [
243 ":counting_semaphore",
244 "//pw_preprocessor",
245 "//pw_unit_test",
246 ],
247)
248
249pw_cc_test(
250 name = "mutex_facade_test",
251 srcs = [
252 "mutex_facade_test.cc",
253 "mutex_facade_test_c.c",
254 ],
255 deps = [
256 ":mutex",
257 "//pw_preprocessor",
258 "//pw_unit_test",
259 ],
260)
261
262pw_cc_test(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700263 name = "timed_mutex_facade_test",
264 srcs = [
265 "timed_mutex_facade_test.cc",
266 "timed_mutex_facade_test_c.c",
267 ],
268 deps = [
269 ":timed_mutex",
270 "//pw_preprocessor",
271 "//pw_unit_test",
272 ],
273)
274
275pw_cc_test(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800276 name = "interrupt_spin_lock_facade_test",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800277 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800278 "interrupt_spin_lock_facade_test.cc",
279 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800280 ],
281 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800282 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800283 "//pw_preprocessor",
284 "//pw_unit_test",
285 ],
286)