blob: e0a474110c689847d99bf1f2c3d6c46b91d89ec2 [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",
17 "pw_cc_library",
18 "pw_cc_test",
19)
20
21package(default_visibility = ["//visibility:public"])
22
23licenses(["notice"]) # Apache License 2.0
24
25# TODO(pwbug/101): Need to add support for facades/backends to Bazel.
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080026PW_SYNC_BINARY_SEMAPHORE_BACKEND = "//pw_sync_stl:binary_semaphore"
27PW_SYNC_COUNTING_SEMAPHORE_BACKEND = "//pw_sync_stl:counting_semaphore"
28PW_SYNC_MUTEX_BACKEND = "//pw_sync_stl:mutex"
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -070029PW_SYNC_TIMED_MUTEX_BACKEND = "//pw_sync_stl:timed_mutex"
Ewout van Bekkum126e0112021-03-12 10:59:49 -080030PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND = "//pw_sync_stl:interrupt_spin_lock"
Ewout van Bekkum58901932020-11-09 12:46:52 -080031
32pw_cc_library(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080033 name = "binary_semaphore_facade",
34 hdrs = [
35 "public/pw_sync/binary_semaphore.h",
36 ],
37 includes = ["public"],
38 srcs = [
39 "binary_semaphore.cc"
40 ],
41 deps = [
42 PW_SYNC_BINARY_SEMAPHORE_BACKEND + "_headers",
43 "//pw_chrono:system_clock",
44 "//pw_preprocessor",
45 ],
46)
47
48pw_cc_library(
49 name = "binary_semaphore",
50 deps = [
51 ":binary_semaphore_facade",
52 PW_SYNC_BINARY_SEMAPHORE_BACKEND + "_headers",
53 ],
54)
55
56pw_cc_library(
57 name = "binary_semaphore_backend",
58 deps = [
59 PW_SYNC_BINARY_SEMAPHORE_BACKEND,
60 ],
61)
62
63pw_cc_library(
64 name = "counting_semaphore_facade",
65 hdrs = [
66 "public/pw_sync/counting_semaphore.h",
67 ],
68 includes = ["public"],
69 srcs = [
70 "counting_semaphore.cc"
71 ],
72 deps = [
73 PW_SYNC_COUNTING_SEMAPHORE_BACKEND + "_headers",
74 "//pw_chrono:system_clock",
75 "//pw_preprocessor",
76 ],
77)
78
79pw_cc_library(
80 name = "counting_semaphore",
81 deps = [
82 ":counting_semaphore_facade",
83 PW_SYNC_COUNTING_SEMAPHORE_BACKEND + "_headers",
84 ],
85)
86
87pw_cc_library(
88 name = "counting_semaphore_backend",
89 deps = [
90 PW_SYNC_COUNTING_SEMAPHORE_BACKEND,
91 ],
92)
93
94pw_cc_library(
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -070095 name = "lock_annotations",
96 hdrs = [
97 "public/pw_sync/lock_annotations.h",
98 ],
99 includes = ["public"],
100 deps = [
101 "//pw_preprocessor",
102 ],
103)
104
105pw_cc_library(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800106 name = "mutex_facade",
107 hdrs = [
108 "public/pw_sync/mutex.h",
109 ],
110 includes = ["public"],
111 srcs = [
112 "mutex.cc"
113 ],
114 deps = [
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700115 ":lock_annotations",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800116 "//pw_preprocessor",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700117 PW_SYNC_MUTEX_BACKEND + "_headers",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800118 ],
119)
120
121pw_cc_library(
122 name = "mutex",
123 deps = [
124 ":mutex_facade",
125 PW_SYNC_MUTEX_BACKEND + "_headers",
126 ],
127)
128
129pw_cc_library(
130 name = "mutex_backend",
131 deps = [
132 PW_SYNC_MUTEX_BACKEND,
133 ],
134)
135
136pw_cc_library(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700137 name = "timed_mutex_facade",
138 hdrs = [
139 "public/pw_sync/timed_mutex.h",
140 ],
141 includes = ["public"],
142 srcs = [
143 "timed_mutex.cc"
144 ],
145 deps = [
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700146 ":lock_annotations",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700147 ":mutex_facade",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700148 "//pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700149 "//pw_preprocessor",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700150 PW_SYNC_TIMED_MUTEX_BACKEND + "_headers",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700151 ],
152)
153
154pw_cc_library(
155 name = "timed_mutex",
156 deps = [
157 ":timed_mutex_facade",
158 PW_SYNC_TIMED_MUTEX_BACKEND + "_headers",
159 ],
160)
161
162pw_cc_library(
163 name = "timed_mutex_backend",
164 deps = [
165 PW_SYNC_TIMED_MUTEX_BACKEND,
166 ],
167)
168
169pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800170 name = "interrupt_spin_lock_facade",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800171 hdrs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800172 "public/pw_sync/interrupt_spin_lock.h",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800173 ],
174 includes = ["public"],
175 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800176 "interrupt_spin_lock.cc"
Ewout van Bekkum58901932020-11-09 12:46:52 -0800177 ],
178 deps = [
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700179 ":lock_annotations",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800180 "//pw_preprocessor",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700181 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800182 ],
183)
184
185pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800186 name = "interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800187 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800188 ":interrupt_spin_lock_facade",
189 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800190 ],
191)
192
193pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800194 name = "interrupt_spin_lock_backend",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800195 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800196 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND,
Ewout van Bekkum58901932020-11-09 12:46:52 -0800197 ],
198)
199
200pw_cc_library(
201 name = "yield_core",
202 hdrs = [
203 "public/pw_sync/yield_core.h",
204 ],
205 includes = ["public"],
206)
207
208pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800209 name = "binary_semaphore_facade_test",
210 srcs = [
211 "binary_semaphore_facade_test.cc",
212 "binary_semaphore_facade_test_c.c",
213 ],
214 deps = [
215 ":binary_semaphore",
216 "//pw_preprocessor",
217 "//pw_unit_test",
218 ],
219)
220
221pw_cc_test(
222 name = "counting_semaphore_facade_test",
223 srcs = [
224 "counting_semaphore_facade_test.cc",
225 "counting_semaphore_facade_test_c.c",
226 ],
227 deps = [
228 ":counting_semaphore",
229 "//pw_preprocessor",
230 "//pw_unit_test",
231 ],
232)
233
234pw_cc_test(
235 name = "mutex_facade_test",
236 srcs = [
237 "mutex_facade_test.cc",
238 "mutex_facade_test_c.c",
239 ],
240 deps = [
241 ":mutex",
242 "//pw_preprocessor",
243 "//pw_unit_test",
244 ],
245)
246
247pw_cc_test(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700248 name = "timed_mutex_facade_test",
249 srcs = [
250 "timed_mutex_facade_test.cc",
251 "timed_mutex_facade_test_c.c",
252 ],
253 deps = [
254 ":timed_mutex",
255 "//pw_preprocessor",
256 "//pw_unit_test",
257 ],
258)
259
260pw_cc_test(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800261 name = "interrupt_spin_lock_facade_test",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800262 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800263 "interrupt_spin_lock_facade_test.cc",
264 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800265 ],
266 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800267 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800268 "//pw_preprocessor",
269 "//pw_unit_test",
270 ],
271)