blob: f1c6620f344076590c0005c5fc8588ef189704ed [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(
95 name = "mutex_facade",
96 hdrs = [
97 "public/pw_sync/mutex.h",
98 ],
99 includes = ["public"],
100 srcs = [
101 "mutex.cc"
102 ],
103 deps = [
104 PW_SYNC_MUTEX_BACKEND + "_headers",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800105 "//pw_preprocessor",
106 ],
107)
108
109pw_cc_library(
110 name = "mutex",
111 deps = [
112 ":mutex_facade",
113 PW_SYNC_MUTEX_BACKEND + "_headers",
114 ],
115)
116
117pw_cc_library(
118 name = "mutex_backend",
119 deps = [
120 PW_SYNC_MUTEX_BACKEND,
121 ],
122)
123
124pw_cc_library(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700125 name = "timed_mutex_facade",
126 hdrs = [
127 "public/pw_sync/timed_mutex.h",
128 ],
129 includes = ["public"],
130 srcs = [
131 "timed_mutex.cc"
132 ],
133 deps = [
134 PW_SYNC_TIMED_MUTEX_BACKEND + "_headers",
135 "//pw_chrono:system_clock",
136 ":mutex_facade",
137 "//pw_preprocessor",
138 ],
139)
140
141pw_cc_library(
142 name = "timed_mutex",
143 deps = [
144 ":timed_mutex_facade",
145 PW_SYNC_TIMED_MUTEX_BACKEND + "_headers",
146 ],
147)
148
149pw_cc_library(
150 name = "timed_mutex_backend",
151 deps = [
152 PW_SYNC_TIMED_MUTEX_BACKEND,
153 ],
154)
155
156pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800157 name = "interrupt_spin_lock_facade",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800158 hdrs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800159 "public/pw_sync/interrupt_spin_lock.h",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800160 ],
161 includes = ["public"],
162 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800163 "interrupt_spin_lock.cc"
Ewout van Bekkum58901932020-11-09 12:46:52 -0800164 ],
165 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800166 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800167 "//pw_preprocessor",
168 ],
169)
170
171pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800172 name = "interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800173 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800174 ":interrupt_spin_lock_facade",
175 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800176 ],
177)
178
179pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800180 name = "interrupt_spin_lock_backend",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800181 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800182 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND,
Ewout van Bekkum58901932020-11-09 12:46:52 -0800183 ],
184)
185
186pw_cc_library(
187 name = "yield_core",
188 hdrs = [
189 "public/pw_sync/yield_core.h",
190 ],
191 includes = ["public"],
192)
193
194pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800195 name = "binary_semaphore_facade_test",
196 srcs = [
197 "binary_semaphore_facade_test.cc",
198 "binary_semaphore_facade_test_c.c",
199 ],
200 deps = [
201 ":binary_semaphore",
202 "//pw_preprocessor",
203 "//pw_unit_test",
204 ],
205)
206
207pw_cc_test(
208 name = "counting_semaphore_facade_test",
209 srcs = [
210 "counting_semaphore_facade_test.cc",
211 "counting_semaphore_facade_test_c.c",
212 ],
213 deps = [
214 ":counting_semaphore",
215 "//pw_preprocessor",
216 "//pw_unit_test",
217 ],
218)
219
220pw_cc_test(
221 name = "mutex_facade_test",
222 srcs = [
223 "mutex_facade_test.cc",
224 "mutex_facade_test_c.c",
225 ],
226 deps = [
227 ":mutex",
228 "//pw_preprocessor",
229 "//pw_unit_test",
230 ],
231)
232
233pw_cc_test(
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700234 name = "timed_mutex_facade_test",
235 srcs = [
236 "timed_mutex_facade_test.cc",
237 "timed_mutex_facade_test_c.c",
238 ],
239 deps = [
240 ":timed_mutex",
241 "//pw_preprocessor",
242 "//pw_unit_test",
243 ],
244)
245
246pw_cc_test(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800247 name = "interrupt_spin_lock_facade_test",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800248 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800249 "interrupt_spin_lock_facade_test.cc",
250 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800251 ],
252 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800253 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800254 "//pw_preprocessor",
255 "//pw_unit_test",
256 ],
257)