blob: 81b7003293d7b975353fabefd5dd9b885e3024b0 [file] [log] [blame]
Ewout van Bekkumf0106062021-05-06 14:08:33 -07001# Copyright 2021 The Pigweed Authors
Ewout van Bekkum58901932020-11-09 12:46:52 -08002#
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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/facade.gni")
18import("$dir_pw_build/target_types.gni")
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -070019import("$dir_pw_chrono/backend.gni")
Ewout van Bekkum58901932020-11-09 12:46:52 -080020import("$dir_pw_docgen/docs.gni")
21import("$dir_pw_unit_test/test.gni")
Wyatt Heplerae93f422020-12-14 11:46:19 -080022import("backend.gni")
Ewout van Bekkum58901932020-11-09 12:46:52 -080023
24config("public_include_path") {
25 include_dirs = [ "public" ]
26 visibility = [ ":*" ]
27}
28
Ewout van Bekkumf0106062021-05-06 14:08:33 -070029config("backend_config") {
30 include_dirs = [ "public_overrides" ]
31 visibility = [ ":*" ]
32}
33
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080034pw_facade("binary_semaphore") {
35 backend = pw_sync_BINARY_SEMAPHORE_BACKEND
36 public_configs = [ ":public_include_path" ]
37 public = [ "public/pw_sync/binary_semaphore.h" ]
38 public_deps = [
39 "$dir_pw_chrono:system_clock",
40 "$dir_pw_preprocessor",
41 ]
42 sources = [ "binary_semaphore.cc" ]
43}
44
45pw_facade("counting_semaphore") {
46 backend = pw_sync_COUNTING_SEMAPHORE_BACKEND
47 public_configs = [ ":public_include_path" ]
48 public = [ "public/pw_sync/counting_semaphore.h" ]
49 public_deps = [
50 "$dir_pw_chrono:system_clock",
51 "$dir_pw_preprocessor",
52 ]
53 sources = [ "counting_semaphore.cc" ]
54}
55
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -070056pw_source_set("lock_annotations") {
57 public_configs = [ ":public_include_path" ]
58 public = [ "public/pw_sync/lock_annotations.h" ]
59 public_deps = [ "$dir_pw_preprocessor" ]
60}
61
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -070062pw_source_set("borrow") {
63 public_configs = [ ":public_include_path" ]
64 public = [ "public/pw_sync/borrow.h" ]
Ewout van Bekkumbaf2fdc2021-09-09 14:11:51 -070065 public_deps = [
Ewout van Bekkumafadef92021-10-20 11:56:06 -070066 ":lock_annotations",
Ewout van Bekkumbaf2fdc2021-09-09 14:11:51 -070067 ":virtual_basic_lockable",
68 dir_pw_assert,
69 ]
70}
71
72pw_source_set("virtual_basic_lockable") {
73 public_configs = [ ":public_include_path" ]
74 public = [ "public/pw_sync/virtual_basic_lockable.h" ]
75 public_deps = [
76 ":lock_annotations",
77 dir_pw_polyfill,
78 ]
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -070079}
80
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080081pw_facade("mutex") {
82 backend = pw_sync_MUTEX_BACKEND
83 public_configs = [ ":public_include_path" ]
84 public = [ "public/pw_sync/mutex.h" ]
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -070085 public_deps = [
86 ":lock_annotations",
Ewout van Bekkumbaf2fdc2021-09-09 14:11:51 -070087 ":virtual_basic_lockable",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -070088 "$dir_pw_preprocessor",
89 ]
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -070090 sources = [ "mutex.cc" ]
91}
92
93pw_facade("timed_mutex") {
94 backend = pw_sync_TIMED_MUTEX_BACKEND
95 public_configs = [ ":public_include_path" ]
96 public = [ "public/pw_sync/timed_mutex.h" ]
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080097 public_deps = [
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -070098 ":mutex",
Ewout van Bekkumbaf2fdc2021-09-09 14:11:51 -070099 ":virtual_basic_lockable",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800100 "$dir_pw_chrono:system_clock",
101 "$dir_pw_preprocessor",
102 ]
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700103 sources = [ "timed_mutex.cc" ]
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800104}
105
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800106pw_facade("interrupt_spin_lock") {
107 backend = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND
108 public_configs = [ ":public_include_path" ]
109 public = [ "public/pw_sync/interrupt_spin_lock.h" ]
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700110 public_deps = [
111 ":lock_annotations",
Ewout van Bekkumbaf2fdc2021-09-09 14:11:51 -0700112 ":virtual_basic_lockable",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700113 "$dir_pw_preprocessor",
114 ]
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800115 sources = [ "interrupt_spin_lock.cc" ]
Ewout van Bekkum58901932020-11-09 12:46:52 -0800116}
117
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700118pw_facade("thread_notification") {
119 backend = pw_sync_THREAD_NOTIFICATION_BACKEND
120 public_configs = [ ":public_include_path" ]
121 public = [ "public/pw_sync/thread_notification.h" ]
122}
123
124pw_facade("timed_thread_notification") {
125 backend = pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND
126 public_configs = [ ":public_include_path" ]
127 public = [ "public/pw_sync/timed_thread_notification.h" ]
128 public_deps = [
129 ":thread_notification",
130 "$dir_pw_chrono:system_clock",
131 ]
132}
133
134# This target provides the backend for pw::sync::ThreadNotification based on
135# pw::sync::BinarySemaphore.
136pw_source_set("binary_semaphore_thread_notification_backend") {
137 public_configs = [
138 ":public_include_path",
139 ":backend_config",
140 ]
141 public = [
142 "public/pw_sync/backends/binary_semaphore_thread_notification_inline.h",
143 "public/pw_sync/backends/binary_semaphore_thread_notification_native.h",
144 "public_overrides/pw_sync_backend/thread_notification_inline.h",
145 "public_overrides/pw_sync_backend/thread_notification_native.h",
146 ]
147 public_deps = [
148 ":binary_semaphore",
149 ":thread_notification.facade",
150 ]
151}
152
153# This target provides the backend for pw::sync::TimedThreadNotification based
154# on pw::sync::BinarySemaphore.
155pw_source_set("binary_semaphore_timed_thread_notification_backend") {
156 public_configs = [
157 ":public_include_path",
158 ":backend_config",
159 ]
160 public = [
161 "public/pw_sync/backends/binary_semaphore_timed_thread_notification_inline.h",
162 "public_overrides/pw_sync_backend/timed_thread_notification_inline.h",
163 ]
164 public_deps = [
165 ":binary_semaphore_thread_notification_backend",
166 ":timed_thread_notification.facade",
167 "$dir_pw_chrono:system_clock",
168 ]
169}
170
Ewout van Bekkum58901932020-11-09 12:46:52 -0800171pw_source_set("yield_core") {
172 public = [ "public/pw_sync/yield_core.h" ]
173 public_configs = [ ":public_include_path" ]
174}
175
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800176pw_test_group("tests") {
177 tests = [
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -0700178 ":borrow_test",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800179 ":binary_semaphore_facade_test",
180 ":counting_semaphore_facade_test",
181 ":mutex_facade_test",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700182 ":timed_mutex_facade_test",
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800183 ":interrupt_spin_lock_facade_test",
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700184 ":thread_notification_facade_test",
185 ":timed_thread_notification_facade_test",
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800186 ]
187}
188
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -0700189pw_test("borrow_test") {
190 sources = [ "borrow_test.cc" ]
191 deps = [
192 ":borrow",
Ewout van Bekkumbaf2fdc2021-09-09 14:11:51 -0700193 ":virtual_basic_lockable",
Ewout van Bekkumf6c3a782021-08-31 11:23:35 -0700194 dir_pw_assert,
195 ]
196}
197
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -0800198pw_test("binary_semaphore_facade_test") {
199 enable_if = pw_sync_BINARY_SEMAPHORE_BACKEND != ""
200 sources = [
201 "binary_semaphore_facade_test.cc",
202 "binary_semaphore_facade_test_c.c",
203 ]
204 deps = [
205 ":binary_semaphore",
206 "$dir_pw_preprocessor",
207 pw_sync_BINARY_SEMAPHORE_BACKEND,
208 ]
209}
210
211pw_test("counting_semaphore_facade_test") {
212 enable_if = pw_sync_COUNTING_SEMAPHORE_BACKEND != ""
213 sources = [
214 "counting_semaphore_facade_test.cc",
215 "counting_semaphore_facade_test_c.c",
216 ]
217 deps = [
218 ":counting_semaphore",
219 "$dir_pw_preprocessor",
220 pw_sync_COUNTING_SEMAPHORE_BACKEND,
221 ]
222}
223
224pw_test("mutex_facade_test") {
225 enable_if = pw_sync_MUTEX_BACKEND != ""
226 sources = [
227 "mutex_facade_test.cc",
228 "mutex_facade_test_c.c",
229 ]
230 deps = [
231 ":mutex",
232 "$dir_pw_preprocessor",
233 pw_sync_MUTEX_BACKEND,
234 ]
235}
236
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700237pw_test("timed_mutex_facade_test") {
238 enable_if = pw_sync_TIMED_MUTEX_BACKEND != ""
239 sources = [
240 "timed_mutex_facade_test.cc",
241 "timed_mutex_facade_test_c.c",
242 ]
243 deps = [
244 ":timed_mutex",
245 "$dir_pw_preprocessor",
246 pw_sync_TIMED_MUTEX_BACKEND,
247 ]
248}
249
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800250pw_test("interrupt_spin_lock_facade_test") {
251 enable_if = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != ""
Ewout van Bekkum58901932020-11-09 12:46:52 -0800252 sources = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800253 "interrupt_spin_lock_facade_test.cc",
254 "interrupt_spin_lock_facade_test_c.c",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800255 ]
256 deps = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800257 ":interrupt_spin_lock",
Ewout van Bekkum58901932020-11-09 12:46:52 -0800258 "$dir_pw_preprocessor",
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800259 pw_sync_INTERRUPT_SPIN_LOCK_BACKEND,
Ewout van Bekkum58901932020-11-09 12:46:52 -0800260 ]
261}
262
Ewout van Bekkumf0106062021-05-06 14:08:33 -0700263pw_test("thread_notification_facade_test") {
264 enable_if = pw_sync_THREAD_NOTIFICATION_BACKEND != ""
265 sources = [ "thread_notification_facade_test.cc" ]
266 deps = [
267 ":thread_notification",
268 pw_sync_THREAD_NOTIFICATION_BACKEND,
269 ]
270}
271
272pw_test("timed_thread_notification_facade_test") {
273 enable_if = pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND != ""
274 sources = [ "timed_thread_notification_facade_test.cc" ]
275 deps = [
276 ":timed_thread_notification",
277 pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND,
278 ]
279}
280
Ewout van Bekkum58901932020-11-09 12:46:52 -0800281pw_doc_group("docs") {
282 sources = [ "docs.rst" ]
283}