blob: fb892c0740f14a9953dfdd3771703547378a87db [file] [log] [blame]
Ewout van Bekkume3b56032020-12-22 12:00:18 -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.
26PW_THREAD_ID_BACKEND = "//pw_thread_stl:id"
27PW_THREAD_SLEEP_BACKEND = "//pw_thread_stl:sleep"
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -080028PW_THREAD_THREAD_BACKEND = "//pw_thread_stl:thread"
Ewout van Bekkume3b56032020-12-22 12:00:18 -080029PW_THREAD_YIELD_BACKEND = "//pw_thread_stl:yield"
30
31pw_cc_library(
32 name = "id_facade",
33 hdrs = [
34 "public/pw_thread/id.h",
35 ],
36 includes = ["public"],
37 deps = [
38 PW_THREAD_ID_BACKEND + "_headers",
39 ],
40)
41
42pw_cc_library(
43 name = "id",
44 deps = [
45 ":id_facade",
46 PW_THREAD_ID_BACKEND + "_headers",
47 ],
48)
49
50pw_cc_library(
51 name = "id_backend",
52 deps = [
53 PW_THREAD_ID_BACKEND,
54 ],
55)
56
57pw_cc_library(
58 name = "sleep_facade",
59 hdrs = [
60 "public/pw_thread/sleep.h",
61 ],
62 includes = ["public"],
63 srcs = [
64 "sleep.cc"
65 ],
66 deps = [
67 PW_THREAD_SLEEP_BACKEND + "_headers",
68 "//pw_chrono:system_clock",
69 "//pw_preprocessor",
70 ],
71)
72
73pw_cc_library(
74 name = "sleep",
75 deps = [
76 ":sleep_facade",
77 PW_THREAD_SLEEP_BACKEND + "_headers",
78 ],
79)
80
81pw_cc_library(
82 name = "sleep_backend",
83 deps = [
84 PW_THREAD_SLEEP_BACKEND,
85 ],
86)
87
88pw_cc_library(
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -080089 name = "thread_facade",
90 hdrs = [
91 "public/pw_thread/thread.h",
92 ],
93 includes = ["public"],
94 deps = [
95 ":id_facade",
96 PW_THREAD_THREAD_BACKEND + "_headers",
97 ],
98)
99
100pw_cc_library(
101 name = "thread",
102 deps = [
103 ":thread_facade",
104 PW_THREAD_THREAD_BACKEND + "_headers",
105 ],
106)
107
108pw_cc_library(
109 name = "thread_backend",
110 deps = [
111 PW_THREAD_THREAD_BACKEND,
112 ],
113)
114
115pw_cc_library(
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800116 name = "yield_facade",
117 hdrs = [
118 "public/pw_thread/yield.h",
119 ],
120 includes = ["public"],
121 srcs = [
122 "yield.cc"
123 ],
124 deps = [
125 PW_THREAD_YIELD_BACKEND + "_headers",
126 "//pw_preprocessor",
127 ],
128)
129
130pw_cc_library(
131 name = "yield",
132 deps = [
133 ":yield_facade",
134 PW_THREAD_YIELD_BACKEND + "_headers",
135 ],
136)
137
138pw_cc_library(
139 name = "yield_backend",
140 deps = [
141 PW_THREAD_YIELD_BACKEND,
142 ],
143)
144
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800145pw_cc_library(
146 name = "test_threads_header",
147 hdrs = [
148 "public/pw_thread/test_threads.h",
149 ],
150 deps = [
151 ":thread",
152 ],
153)
154
155# To instantiate this as a pw_cc_test, depend on this pw_cc_library and the
156# pw_cc_library which implements the backend for test_threads_header. See
157# //pw_thread:thread_backend_test as an example.
158pw_cc_library(
159 name = "thread_facade_test",
160 srcs = [
161 "thread_facade_test.cc",
162 ],
163 deps = [
164 ":thread",
165 ":id",
166 ":test_threads_header",
Ewout van Bekkumae6c03a2021-01-19 14:53:19 -0800167 "//pw_chrono:system_clock",
168 "//pw_sync:binary_semaphore",
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800169 "//pw_unit_test",
170 ],
171)
172
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800173pw_cc_test(
174 name = "id_facade_test",
175 srcs = [
176 "id_facade_test.cc",
177 ],
178 deps = [
179 ":id",
180 "//pw_unit_test",
181 ],
182)
183
184pw_cc_test(
185 name = "sleep_facade_test",
186 srcs = [
187 "sleep_facade_test.cc",
188 "sleep_facade_test_c.c",
189 ],
190 deps = [
191 ":sleep",
192 "//pw_chrono:system_clock",
193 "//pw_preprocessor",
194 "//pw_unit_test",
195 ],
196)
197
198pw_cc_test(
199 name = "yield_facade_test",
200 srcs = [
201 "yield_facade_test.cc",
202 "yield_facade_test_c.c",
203 ],
204 deps = [
205 ":yield",
206 "//pw_preprocessor",
207 "//pw_unit_test",
208 ],
209)