blob: 11e793aa6dab147501c7e1193853081c32815994 [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"
Nathaniel Brougha1113be2021-03-07 09:05:41 +080027
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080028PW_SYNC_COUNTING_SEMAPHORE_BACKEND = "//pw_sync_stl:counting_semaphore"
Nathaniel Brougha1113be2021-03-07 09:05:41 +080029
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080030PW_SYNC_MUTEX_BACKEND = "//pw_sync_stl:mutex"
Nathaniel Brougha1113be2021-03-07 09:05:41 +080031
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -070032PW_SYNC_TIMED_MUTEX_BACKEND = "//pw_sync_stl:timed_mutex"
Nathaniel Brougha1113be2021-03-07 09:05:41 +080033
Ewout van Bekkum126e0112021-03-12 10:59:49 -080034PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND = "//pw_sync_stl:interrupt_spin_lock"
Ewout van Bekkum58901932020-11-09 12:46:52 -080035
36pw_cc_library(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080037 name = "binary_semaphore_facade",
Nathaniel Brougha1113be2021-03-07 09:05:41 +080038 srcs = [
39 "binary_semaphore.cc",
40 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080041 hdrs = [
42 "public/pw_sync/binary_semaphore.h",
43 ],
44 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080045 deps = [
46 PW_SYNC_BINARY_SEMAPHORE_BACKEND + "_headers",
47 "//pw_chrono:system_clock",
48 "//pw_preprocessor",
49 ],
50)
51
52pw_cc_library(
53 name = "binary_semaphore",
54 deps = [
55 ":binary_semaphore_facade",
56 PW_SYNC_BINARY_SEMAPHORE_BACKEND + "_headers",
57 ],
58)
59
60pw_cc_library(
61 name = "binary_semaphore_backend",
62 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +080063 PW_SYNC_BINARY_SEMAPHORE_BACKEND,
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080064 ],
65)
66
67pw_cc_library(
68 name = "counting_semaphore_facade",
Nathaniel Brougha1113be2021-03-07 09:05:41 +080069 srcs = [
70 "counting_semaphore.cc",
71 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080072 hdrs = [
73 "public/pw_sync/counting_semaphore.h",
74 ],
75 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080076 deps = [
77 PW_SYNC_COUNTING_SEMAPHORE_BACKEND + "_headers",
78 "//pw_chrono:system_clock",
79 "//pw_preprocessor",
80 ],
81)
82
83pw_cc_library(
84 name = "counting_semaphore",
85 deps = [
86 ":counting_semaphore_facade",
87 PW_SYNC_COUNTING_SEMAPHORE_BACKEND + "_headers",
88 ],
89)
90
91pw_cc_library(
92 name = "counting_semaphore_backend",
93 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +080094 PW_SYNC_COUNTING_SEMAPHORE_BACKEND,
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080095 ],
96)
97
98pw_cc_library(
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -070099 name = "lock_annotations",
100 hdrs = [
101 "public/pw_sync/lock_annotations.h",
102 ],
103 includes = ["public"],
104 deps = [
105 "//pw_preprocessor",
106 ],
107)
108
109pw_cc_library(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800110 name = "mutex_facade",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800111 srcs = [
112 "mutex.cc",
113 ],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800114 hdrs = [
115 "public/pw_sync/mutex.h",
116 ],
117 includes = ["public"],
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800118 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800119 ":lock_annotations",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800120 "//pw_preprocessor",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700121 PW_SYNC_MUTEX_BACKEND + "_headers",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800122 ],
123)
124
125pw_cc_library(
126 name = "mutex",
127 deps = [
128 ":mutex_facade",
129 PW_SYNC_MUTEX_BACKEND + "_headers",
130 ],
131)
132
133pw_cc_library(
134 name = "mutex_backend",
135 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800136 PW_SYNC_MUTEX_BACKEND,
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800137 ],
138)
139
140pw_cc_library(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700141 name = "timed_mutex_facade",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800142 srcs = [
143 "timed_mutex.cc",
144 ],
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700145 hdrs = [
146 "public/pw_sync/timed_mutex.h",
147 ],
148 includes = ["public"],
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700149 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800150 ":lock_annotations",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700151 ":mutex_facade",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700152 "//pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700153 "//pw_preprocessor",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700154 PW_SYNC_TIMED_MUTEX_BACKEND + "_headers",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700155 ],
156)
157
158pw_cc_library(
159 name = "timed_mutex",
160 deps = [
161 ":timed_mutex_facade",
162 PW_SYNC_TIMED_MUTEX_BACKEND + "_headers",
163 ],
164)
165
166pw_cc_library(
167 name = "timed_mutex_backend",
168 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800169 PW_SYNC_TIMED_MUTEX_BACKEND,
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700170 ],
171)
172
173pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800174 name = "interrupt_spin_lock_facade",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800175 srcs = [
176 "interrupt_spin_lock.cc",
177 ],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800178 hdrs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800179 "public/pw_sync/interrupt_spin_lock.h",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800180 ],
181 includes = ["public"],
Ewout van Bekkum58901932020-11-09 12:46:52 -0800182 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800183 ":lock_annotations",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800184 "//pw_preprocessor",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700185 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800186 ],
187)
188
189pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800190 name = "interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800191 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800192 ":interrupt_spin_lock_facade",
193 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800194 ],
195)
196
197pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800198 name = "interrupt_spin_lock_backend",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800199 deps = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800200 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND,
Ewout van Bekkum58901932020-11-09 12:46:52 -0800201 ],
202)
203
204pw_cc_library(
205 name = "yield_core",
206 hdrs = [
207 "public/pw_sync/yield_core.h",
208 ],
209 includes = ["public"],
210)
211
212pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800213 name = "binary_semaphore_facade_test",
214 srcs = [
215 "binary_semaphore_facade_test.cc",
216 "binary_semaphore_facade_test_c.c",
217 ],
218 deps = [
219 ":binary_semaphore",
220 "//pw_preprocessor",
221 "//pw_unit_test",
222 ],
223)
224
225pw_cc_test(
226 name = "counting_semaphore_facade_test",
227 srcs = [
228 "counting_semaphore_facade_test.cc",
229 "counting_semaphore_facade_test_c.c",
230 ],
231 deps = [
232 ":counting_semaphore",
233 "//pw_preprocessor",
234 "//pw_unit_test",
235 ],
236)
237
238pw_cc_test(
239 name = "mutex_facade_test",
240 srcs = [
241 "mutex_facade_test.cc",
242 "mutex_facade_test_c.c",
243 ],
244 deps = [
245 ":mutex",
246 "//pw_preprocessor",
247 "//pw_unit_test",
248 ],
249)
250
251pw_cc_test(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700252 name = "timed_mutex_facade_test",
253 srcs = [
254 "timed_mutex_facade_test.cc",
255 "timed_mutex_facade_test_c.c",
256 ],
257 deps = [
258 ":timed_mutex",
259 "//pw_preprocessor",
260 "//pw_unit_test",
261 ],
262)
263
264pw_cc_test(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800265 name = "interrupt_spin_lock_facade_test",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800266 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800267 "interrupt_spin_lock_facade_test.cc",
268 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800269 ],
270 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800271 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800272 "//pw_preprocessor",
273 "//pw_unit_test",
274 ],
275)