blob: 9c8c456ec0fde5992f8bcad28e6f674371714674 [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
24licenses(["notice"]) # Apache License 2.0
25
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 = [
91 "public/pw_thread/thread.h",
Ewout van Bekkum19e753a2021-04-28 18:06:55 -070092 "public/pw_thread/detached_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 ],
105 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800106 ":id",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800107 ":thread_core",
108 ":thread_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800109 "@pigweed_config//:pw_thread_thread_backend",
Ewout van Bekkuma082d7f2021-04-15 14:36:37 -0700110 ],
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800111)
112
113pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800114 name = "thread_backend_multiplexer",
115 visibility = ["@pigweed_config//:__pkg__"],
116 deps = select({
117 "//pw_build/constraints/rtos:embos": ["//pw_thread_embos:thread"],
118 "//pw_build/constraints/rtos:freertos": ["//pw_thread_freertos:thread"],
119 "//pw_build/constraints/rtos:threadx": ["//pw_thread_threadx:thread"],
120 "//conditions:default": ["//pw_thread_stl:thread"],
121 }),
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800122)
123
124pw_cc_library(
Ewout van Bekkuma082d7f2021-04-15 14:36:37 -0700125 name = "thread_core",
126 hdrs = [
127 "public/pw_thread/thread_core.h",
128 ],
129 includes = ["public"],
130)
131
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800132pw_cc_facade(
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800133 name = "yield_facade",
134 hdrs = [
135 "public/pw_thread/yield.h",
136 ],
137 includes = ["public"],
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800138 deps = [
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800139 "//pw_preprocessor",
140 ],
141)
142
143pw_cc_library(
144 name = "yield",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800145 srcs = [
146 "yield.cc",
147 ],
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800148 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800149 ":id",
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800150 ":yield_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800151 "@pigweed_config//:pw_thread_yield_backend",
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800152 ],
153)
154
155pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800156 name = "yield_backend_multiplexer",
157 visibility = ["@pigweed_config//:__pkg__"],
158 deps = select({
159 "//pw_build/constraints/rtos:embos": ["//pw_thread_embos:yield"],
160 "//pw_build/constraints/rtos:freertos": ["//pw_thread_freertos:yield"],
161 "//pw_build/constraints/rtos:threadx": ["//pw_thread_threadx:yield"],
162 "//conditions:default": ["//pw_thread_stl:yield"],
163 }),
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800164)
165
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800166pw_cc_library(
167 name = "test_threads_header",
168 hdrs = [
169 "public/pw_thread/test_threads.h",
170 ],
171 deps = [
172 ":thread",
173 ],
174)
175
176# To instantiate this as a pw_cc_test, depend on this pw_cc_library and the
177# pw_cc_library which implements the backend for test_threads_header. See
178# //pw_thread:thread_backend_test as an example.
179pw_cc_library(
180 name = "thread_facade_test",
181 srcs = [
182 "thread_facade_test.cc",
183 ],
184 deps = [
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800185 ":id",
186 ":test_threads_header",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800187 ":thread",
Ewout van Bekkumae6c03a2021-01-19 14:53:19 -0800188 "//pw_chrono:system_clock",
189 "//pw_sync:binary_semaphore",
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800190 "//pw_unit_test",
191 ],
192)
193
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800194pw_cc_test(
195 name = "id_facade_test",
196 srcs = [
197 "id_facade_test.cc",
198 ],
199 deps = [
200 ":id",
201 "//pw_unit_test",
202 ],
203)
204
205pw_cc_test(
206 name = "sleep_facade_test",
207 srcs = [
208 "sleep_facade_test.cc",
209 "sleep_facade_test_c.c",
210 ],
211 deps = [
212 ":sleep",
213 "//pw_chrono:system_clock",
214 "//pw_preprocessor",
215 "//pw_unit_test",
216 ],
217)
218
219pw_cc_test(
220 name = "yield_facade_test",
221 srcs = [
222 "yield_facade_test.cc",
223 "yield_facade_test_c.c",
224 ],
225 deps = [
226 ":yield",
227 "//pw_preprocessor",
228 "//pw_unit_test",
229 ],
230)