blob: 058c4f0d3118d1c5e2aed16c31f3380eb820aaad [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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/facade.gni")
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_unit_test/test.gni")
21
22declare_args() {
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080023 # Backend for the pw_sync module's binary semaphore.
24 pw_sync_BINARY_SEMAPHORE_BACKEND = ""
25
26 # Backend for the pw_sync module's counting semaphore.
27 pw_sync_COUNTING_SEMAPHORE_BACKEND = ""
28
29 # Backend for the pw_sync module's mutex.
30 pw_sync_MUTEX_BACKEND = ""
31
Ewout van Bekkum58901932020-11-09 12:46:52 -080032 # Backend for the pw_sync module's spin lock.
33 pw_sync_SPIN_LOCK_BACKEND = ""
34}
35
36config("public_include_path") {
37 include_dirs = [ "public" ]
38 visibility = [ ":*" ]
39}
40
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080041pw_facade("binary_semaphore") {
42 backend = pw_sync_BINARY_SEMAPHORE_BACKEND
43 public_configs = [ ":public_include_path" ]
44 public = [ "public/pw_sync/binary_semaphore.h" ]
45 public_deps = [
46 "$dir_pw_chrono:system_clock",
47 "$dir_pw_preprocessor",
48 ]
49 sources = [ "binary_semaphore.cc" ]
50}
51
52pw_facade("counting_semaphore") {
53 backend = pw_sync_COUNTING_SEMAPHORE_BACKEND
54 public_configs = [ ":public_include_path" ]
55 public = [ "public/pw_sync/counting_semaphore.h" ]
56 public_deps = [
57 "$dir_pw_chrono:system_clock",
58 "$dir_pw_preprocessor",
59 ]
60 sources = [ "counting_semaphore.cc" ]
61}
62
63pw_facade("mutex") {
64 backend = pw_sync_MUTEX_BACKEND
65 public_configs = [ ":public_include_path" ]
66 public = [ "public/pw_sync/mutex.h" ]
67 public_deps = [
68 "$dir_pw_chrono:system_clock",
69 "$dir_pw_preprocessor",
70 ]
71 sources = [ "mutex.cc" ]
72}
73
Ewout van Bekkum58901932020-11-09 12:46:52 -080074pw_facade("spin_lock") {
75 backend = pw_sync_SPIN_LOCK_BACKEND
76 public_configs = [ ":public_include_path" ]
77 public = [ "public/pw_sync/spin_lock.h" ]
78 public_deps = [ "$dir_pw_preprocessor" ]
79 sources = [ "spin_lock.cc" ]
80}
81
Ewout van Bekkum58901932020-11-09 12:46:52 -080082pw_source_set("yield_core") {
83 public = [ "public/pw_sync/yield_core.h" ]
84 public_configs = [ ":public_include_path" ]
85}
86
Ewout van Bekkum9618d8a2020-11-09 12:46:52 -080087pw_test_group("tests") {
88 tests = [
89 ":binary_semaphore_facade_test",
90 ":counting_semaphore_facade_test",
91 ":mutex_facade_test",
92 ":spin_lock_facade_test",
93 ]
94}
95
96pw_test("binary_semaphore_facade_test") {
97 enable_if = pw_sync_BINARY_SEMAPHORE_BACKEND != ""
98 sources = [
99 "binary_semaphore_facade_test.cc",
100 "binary_semaphore_facade_test_c.c",
101 ]
102 deps = [
103 ":binary_semaphore",
104 "$dir_pw_preprocessor",
105 pw_sync_BINARY_SEMAPHORE_BACKEND,
106 ]
107}
108
109pw_test("counting_semaphore_facade_test") {
110 enable_if = pw_sync_COUNTING_SEMAPHORE_BACKEND != ""
111 sources = [
112 "counting_semaphore_facade_test.cc",
113 "counting_semaphore_facade_test_c.c",
114 ]
115 deps = [
116 ":counting_semaphore",
117 "$dir_pw_preprocessor",
118 pw_sync_COUNTING_SEMAPHORE_BACKEND,
119 ]
120}
121
122pw_test("mutex_facade_test") {
123 enable_if = pw_sync_MUTEX_BACKEND != ""
124 sources = [
125 "mutex_facade_test.cc",
126 "mutex_facade_test_c.c",
127 ]
128 deps = [
129 ":mutex",
130 "$dir_pw_preprocessor",
131 pw_sync_MUTEX_BACKEND,
132 ]
133}
134
Ewout van Bekkum58901932020-11-09 12:46:52 -0800135pw_test("spin_lock_facade_test") {
136 enable_if = pw_sync_SPIN_LOCK_BACKEND != ""
137 sources = [
138 "spin_lock_facade_test.cc",
139 "spin_lock_facade_test_c.c",
140 ]
141 deps = [
142 ":spin_lock",
143 "$dir_pw_preprocessor",
144 pw_sync_SPIN_LOCK_BACKEND,
145 ]
146}
147
148pw_doc_group("docs") {
149 sources = [ "docs.rst" ]
150}