blob: 71511780ed289e95f8053e2dae84267962cbcabe [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 Bekkum126e0112021-03-12 10:59:49 -080029PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND = "//pw_sync_stl:interrupt_spin_lock"
Ewout van Bekkum58901932020-11-09 12:46:52 -080030
31pw_cc_library(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080032 name = "binary_semaphore_facade",
33 hdrs = [
34 "public/pw_sync/binary_semaphore.h",
35 ],
36 includes = ["public"],
37 srcs = [
38 "binary_semaphore.cc"
39 ],
40 deps = [
41 PW_SYNC_BINARY_SEMAPHORE_BACKEND + "_headers",
42 "//pw_chrono:system_clock",
43 "//pw_preprocessor",
44 ],
45)
46
47pw_cc_library(
48 name = "binary_semaphore",
49 deps = [
50 ":binary_semaphore_facade",
51 PW_SYNC_BINARY_SEMAPHORE_BACKEND + "_headers",
52 ],
53)
54
55pw_cc_library(
56 name = "binary_semaphore_backend",
57 deps = [
58 PW_SYNC_BINARY_SEMAPHORE_BACKEND,
59 ],
60)
61
62pw_cc_library(
63 name = "counting_semaphore_facade",
64 hdrs = [
65 "public/pw_sync/counting_semaphore.h",
66 ],
67 includes = ["public"],
68 srcs = [
69 "counting_semaphore.cc"
70 ],
71 deps = [
72 PW_SYNC_COUNTING_SEMAPHORE_BACKEND + "_headers",
73 "//pw_chrono:system_clock",
74 "//pw_preprocessor",
75 ],
76)
77
78pw_cc_library(
79 name = "counting_semaphore",
80 deps = [
81 ":counting_semaphore_facade",
82 PW_SYNC_COUNTING_SEMAPHORE_BACKEND + "_headers",
83 ],
84)
85
86pw_cc_library(
87 name = "counting_semaphore_backend",
88 deps = [
89 PW_SYNC_COUNTING_SEMAPHORE_BACKEND,
90 ],
91)
92
93pw_cc_library(
94 name = "mutex_facade",
95 hdrs = [
96 "public/pw_sync/mutex.h",
97 ],
98 includes = ["public"],
99 srcs = [
100 "mutex.cc"
101 ],
102 deps = [
103 PW_SYNC_MUTEX_BACKEND + "_headers",
104 "//pw_chrono:system_clock",
105 "//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 Bekkum126e0112021-03-12 10:59:49 -0800125 name = "interrupt_spin_lock_facade",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800126 hdrs = [
127 "public/pw_sync/spin_lock.h",
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800128 "public/pw_sync/interrupt_spin_lock.h",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800129 ],
130 includes = ["public"],
131 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800132 "interrupt_spin_lock.cc"
Ewout van Bekkum58901932020-11-09 12:46:52 -0800133 ],
134 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800135 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800136 "//pw_preprocessor",
137 ],
138)
139
140pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800141 name = "interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800142 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800143 ":interrupt_spin_lock_facade",
144 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800145 ],
146)
147
148pw_cc_library(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800149 name = "interrupt_spin_lock_backend",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800150 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800151 PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND,
Ewout van Bekkum58901932020-11-09 12:46:52 -0800152 ],
153)
154
155pw_cc_library(
156 name = "yield_core",
157 hdrs = [
158 "public/pw_sync/yield_core.h",
159 ],
160 includes = ["public"],
161)
162
163pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800164 name = "binary_semaphore_facade_test",
165 srcs = [
166 "binary_semaphore_facade_test.cc",
167 "binary_semaphore_facade_test_c.c",
168 ],
169 deps = [
170 ":binary_semaphore",
171 "//pw_preprocessor",
172 "//pw_unit_test",
173 ],
174)
175
176pw_cc_test(
177 name = "counting_semaphore_facade_test",
178 srcs = [
179 "counting_semaphore_facade_test.cc",
180 "counting_semaphore_facade_test_c.c",
181 ],
182 deps = [
183 ":counting_semaphore",
184 "//pw_preprocessor",
185 "//pw_unit_test",
186 ],
187)
188
189pw_cc_test(
190 name = "mutex_facade_test",
191 srcs = [
192 "mutex_facade_test.cc",
193 "mutex_facade_test_c.c",
194 ],
195 deps = [
196 ":mutex",
197 "//pw_preprocessor",
198 "//pw_unit_test",
199 ],
200)
201
202pw_cc_test(
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800203 name = "interrupt_spin_lock_facade_test",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800204 srcs = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800205 "interrupt_spin_lock_facade_test.cc",
206 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800207 ],
208 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800209 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800210 "//pw_preprocessor",
211 "//pw_unit_test",
212 ],
213)