blob: 6b2daa66bf2d3435df08ffa39f50caeb97a330ab [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",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080017 "pw_cc_facade",
Ewout van Bekkume3b56032020-12-22 12:00:18 -080018 "pw_cc_library",
19 "pw_cc_test",
20)
21
22package(default_visibility = ["//visibility:public"])
23
Rob Mohr5fc25412021-06-23 09:35:23 -070024licenses(["notice"])
Ewout van Bekkume3b56032020-12-22 12:00:18 -080025
Nathaniel Broughc2d57812021-04-18 22:52:00 +080026pw_cc_facade(
Ewout van Bekkume3b56032020-12-22 12:00:18 -080027 name = "id_facade",
28 hdrs = [
29 "public/pw_thread/id.h",
30 ],
31 includes = ["public"],
Ewout van Bekkume3b56032020-12-22 12:00:18 -080032)
33
34pw_cc_library(
35 name = "id",
36 deps = [
37 ":id_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080038 "@pigweed_config//:pw_thread_id_backend",
Ewout van Bekkume3b56032020-12-22 12:00:18 -080039 ],
40)
41
42pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +080043 name = "id_backend_multiplexer",
44 visibility = ["@pigweed_config//:__pkg__"],
45 deps = select({
46 "//pw_build/constraints/rtos:embos": ["//pw_thread_embos:id"],
47 "//pw_build/constraints/rtos:freertos": ["//pw_thread_freertos:id"],
48 "//pw_build/constraints/rtos:threadx": ["//pw_thread_threadx:id"],
49 "//conditions:default": ["//pw_thread_stl:id"],
50 }),
Ewout van Bekkume3b56032020-12-22 12:00:18 -080051)
52
Nathaniel Broughc2d57812021-04-18 22:52:00 +080053pw_cc_facade(
Ewout van Bekkume3b56032020-12-22 12:00:18 -080054 name = "sleep_facade",
55 hdrs = [
56 "public/pw_thread/sleep.h",
57 ],
58 includes = ["public"],
Ewout van Bekkume3b56032020-12-22 12:00:18 -080059 deps = [
Ewout van Bekkume3b56032020-12-22 12:00:18 -080060 "//pw_chrono:system_clock",
61 "//pw_preprocessor",
62 ],
63)
64
65pw_cc_library(
66 name = "sleep",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080067 srcs = [
68 "sleep.cc",
69 ],
Ewout van Bekkume3b56032020-12-22 12:00:18 -080070 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +080071 ":id",
Ewout van Bekkume3b56032020-12-22 12:00:18 -080072 ":sleep_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080073 "@pigweed_config//:pw_thread_sleep_backend",
Ewout van Bekkume3b56032020-12-22 12:00:18 -080074 ],
75)
76
77pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +080078 name = "sleep_backend_multiplexer",
79 visibility = ["@pigweed_config//:__pkg__"],
80 deps = select({
81 "//pw_build/constraints/rtos:embos": ["//pw_thread_embos:sleep"],
82 "//pw_build/constraints/rtos:freertos": ["//pw_thread_freertos:sleep"],
83 "//pw_build/constraints/rtos:threadx": ["//pw_thread_threadx:sleep"],
84 "//conditions:default": ["//pw_thread_stl:sleep"],
85 }),
Ewout van Bekkume3b56032020-12-22 12:00:18 -080086)
87
Nathaniel Broughc2d57812021-04-18 22:52:00 +080088pw_cc_facade(
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -080089 name = "thread_facade",
90 hdrs = [
Ewout van Bekkum19e753a2021-04-28 18:06:55 -070091 "public/pw_thread/detached_thread.h",
Rob Mohr10663e22021-05-14 12:48:35 -070092 "public/pw_thread/thread.h",
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -080093 ],
94 includes = ["public"],
95 deps = [
96 ":id_facade",
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -080097 ],
98)
99
100pw_cc_library(
101 name = "thread",
Ewout van Bekkuma082d7f2021-04-15 14:36:37 -0700102 srcs = [
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800103 "thread.cc",
104 ],
Rob Mohr2031ac02021-08-16 08:05:31 -0700105 hdrs = ["public/pw_thread/config.h"],
106 includes = ["public"],
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800107 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800108 ":id",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800109 ":thread_core",
110 ":thread_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800111 "@pigweed_config//:pw_thread_thread_backend",
Ewout van Bekkuma082d7f2021-04-15 14:36:37 -0700112 ],
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800113)
114
115pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800116 name = "thread_backend_multiplexer",
117 visibility = ["@pigweed_config//:__pkg__"],
118 deps = select({
119 "//pw_build/constraints/rtos:embos": ["//pw_thread_embos:thread"],
120 "//pw_build/constraints/rtos:freertos": ["//pw_thread_freertos:thread"],
121 "//pw_build/constraints/rtos:threadx": ["//pw_thread_threadx:thread"],
122 "//conditions:default": ["//pw_thread_stl:thread"],
123 }),
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800124)
125
126pw_cc_library(
Ewout van Bekkuma082d7f2021-04-15 14:36:37 -0700127 name = "thread_core",
128 hdrs = [
129 "public/pw_thread/thread_core.h",
130 ],
131 includes = ["public"],
132)
133
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800134pw_cc_facade(
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800135 name = "yield_facade",
136 hdrs = [
137 "public/pw_thread/yield.h",
138 ],
139 includes = ["public"],
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800140 deps = [
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800141 "//pw_preprocessor",
142 ],
143)
144
145pw_cc_library(
146 name = "yield",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800147 srcs = [
148 "yield.cc",
149 ],
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800150 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800151 ":id",
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800152 ":yield_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800153 "@pigweed_config//:pw_thread_yield_backend",
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800154 ],
155)
156
157pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800158 name = "yield_backend_multiplexer",
159 visibility = ["@pigweed_config//:__pkg__"],
160 deps = select({
161 "//pw_build/constraints/rtos:embos": ["//pw_thread_embos:yield"],
162 "//pw_build/constraints/rtos:freertos": ["//pw_thread_freertos:yield"],
163 "//pw_build/constraints/rtos:threadx": ["//pw_thread_threadx:yield"],
164 "//conditions:default": ["//pw_thread_stl:yield"],
165 }),
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800166)
167
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800168pw_cc_library(
Armando Montanezfec572b2021-06-28 12:13:57 -0700169 name = "snapshot",
Armando Montanezfec572b2021-06-28 12:13:57 -0700170 srcs = [
Rob Mohre93dc3b2021-07-12 07:28:32 -0700171 "snapshot.cc",
172 ],
173 hdrs = [
174 "public/pw_thread/snapshot.h",
Armando Montanezfec572b2021-06-28 12:13:57 -0700175 ],
176 deps = [
177 ":util",
Armando Montanezfec572b2021-06-28 12:13:57 -0700178 "//pw_bytes",
179 "//pw_function",
Rob Mohre93dc3b2021-07-12 07:28:32 -0700180 "//pw_log",
Armando Montanezfec572b2021-06-28 12:13:57 -0700181 "//pw_protobuf",
182 "//pw_status",
Rob Mohre93dc3b2021-07-12 07:28:32 -0700183 "//pw_thread:protos",
Armando Montanezfec572b2021-06-28 12:13:57 -0700184 ],
185)
186
187pw_cc_library(
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800188 name = "test_threads_header",
189 hdrs = [
190 "public/pw_thread/test_threads.h",
191 ],
192 deps = [
193 ":thread",
194 ],
195)
196
197# To instantiate this as a pw_cc_test, depend on this pw_cc_library and the
198# pw_cc_library which implements the backend for test_threads_header. See
199# //pw_thread:thread_backend_test as an example.
200pw_cc_library(
201 name = "thread_facade_test",
202 srcs = [
203 "thread_facade_test.cc",
204 ],
205 deps = [
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800206 ":id",
207 ":test_threads_header",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800208 ":thread",
Ewout van Bekkumae6c03a2021-01-19 14:53:19 -0800209 "//pw_chrono:system_clock",
210 "//pw_sync:binary_semaphore",
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800211 "//pw_unit_test",
212 ],
213)
214
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800215pw_cc_test(
216 name = "id_facade_test",
217 srcs = [
218 "id_facade_test.cc",
219 ],
220 deps = [
221 ":id",
222 "//pw_unit_test",
223 ],
224)
225
226pw_cc_test(
227 name = "sleep_facade_test",
228 srcs = [
229 "sleep_facade_test.cc",
230 "sleep_facade_test_c.c",
231 ],
232 deps = [
233 ":sleep",
234 "//pw_chrono:system_clock",
235 "//pw_preprocessor",
236 "//pw_unit_test",
237 ],
238)
239
240pw_cc_test(
241 name = "yield_facade_test",
242 srcs = [
243 "yield_facade_test.cc",
244 "yield_facade_test_c.c",
245 ],
246 deps = [
247 ":yield",
248 "//pw_preprocessor",
249 "//pw_unit_test",
250 ],
251)