blob: 18d19622e27ef1637c25de0994445463e59a96b2 [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 Bekkum58901932020-11-09 12:46:52 -080029PW_SYNC_SPIN_LOCK_BACKEND = "//pw_sync_stl:spin_lock"
30
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 Bekkum58901932020-11-09 12:46:52 -0800125 name = "spin_lock_facade",
126 hdrs = [
127 "public/pw_sync/spin_lock.h",
128 ],
129 includes = ["public"],
130 srcs = [
131 "spin_lock.cc"
132 ],
133 deps = [
134 PW_SYNC_SPIN_LOCK_BACKEND + "_headers",
135 "//pw_preprocessor",
136 ],
137)
138
139pw_cc_library(
140 name = "spin_lock",
141 deps = [
142 ":spin_lock_facade",
143 PW_SYNC_SPIN_LOCK_BACKEND + "_headers",
144 ],
145)
146
147pw_cc_library(
148 name = "spin_lock_backend",
149 deps = [
150 PW_SYNC_SPIN_LOCK_BACKEND,
151 ],
152)
153
154pw_cc_library(
155 name = "yield_core",
156 hdrs = [
157 "public/pw_sync/yield_core.h",
158 ],
159 includes = ["public"],
160)
161
162pw_cc_test(
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800163 name = "binary_semaphore_facade_test",
164 srcs = [
165 "binary_semaphore_facade_test.cc",
166 "binary_semaphore_facade_test_c.c",
167 ],
168 deps = [
169 ":binary_semaphore",
170 "//pw_preprocessor",
171 "//pw_unit_test",
172 ],
173)
174
175pw_cc_test(
176 name = "counting_semaphore_facade_test",
177 srcs = [
178 "counting_semaphore_facade_test.cc",
179 "counting_semaphore_facade_test_c.c",
180 ],
181 deps = [
182 ":counting_semaphore",
183 "//pw_preprocessor",
184 "//pw_unit_test",
185 ],
186)
187
188pw_cc_test(
189 name = "mutex_facade_test",
190 srcs = [
191 "mutex_facade_test.cc",
192 "mutex_facade_test_c.c",
193 ],
194 deps = [
195 ":mutex",
196 "//pw_preprocessor",
197 "//pw_unit_test",
198 ],
199)
200
201pw_cc_test(
Ewout van Bekkum58901932020-11-09 12:46:52 -0800202 name = "spin_lock_facade_test",
203 srcs = [
204 "spin_lock_facade_test.cc",
205 "spin_lock_facade_test_c.c",
206 ],
207 deps = [
208 ":spin_lock",
209 "//pw_preprocessor",
210 "//pw_unit_test",
211 ],
212)