• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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_facade",
18    "pw_cc_library",
19    "pw_cc_test",
20)
21
22package(default_visibility = ["//visibility:public"])
23
24licenses(["notice"])
25
26pw_cc_facade(
27    name = "id_facade",
28    hdrs = [
29        "public/pw_thread/id.h",
30    ],
31    includes = ["public"],
32)
33
34pw_cc_library(
35    name = "id",
36    deps = [
37        ":id_facade",
38        "@pigweed_config//:pw_thread_id_backend",
39    ],
40)
41
42pw_cc_library(
43    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    }),
51)
52
53pw_cc_facade(
54    name = "sleep_facade",
55    hdrs = [
56        "public/pw_thread/sleep.h",
57    ],
58    includes = ["public"],
59    deps = [
60        "//pw_chrono:system_clock",
61        "//pw_preprocessor",
62    ],
63)
64
65pw_cc_library(
66    name = "sleep",
67    srcs = [
68        "sleep.cc",
69    ],
70    deps = [
71        ":id",
72        ":sleep_facade",
73        "@pigweed_config//:pw_thread_sleep_backend",
74    ],
75)
76
77pw_cc_library(
78    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    }),
86)
87
88pw_cc_facade(
89    name = "thread_facade",
90    hdrs = [
91        "public/pw_thread/detached_thread.h",
92        "public/pw_thread/thread.h",
93    ],
94    includes = ["public"],
95    deps = [
96        ":id_facade",
97    ],
98)
99
100pw_cc_library(
101    name = "thread",
102    srcs = [
103        "thread.cc",
104    ],
105    hdrs = ["public/pw_thread/config.h"],
106    includes = ["public"],
107    deps = [
108        ":id",
109        ":thread_core",
110        ":thread_facade",
111        "@pigweed_config//:pw_thread_thread_backend",
112    ],
113)
114
115pw_cc_library(
116    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    }),
124)
125
126pw_cc_library(
127    name = "thread_core",
128    hdrs = [
129        "public/pw_thread/thread_core.h",
130    ],
131    includes = ["public"],
132)
133
134pw_cc_facade(
135    name = "yield_facade",
136    hdrs = [
137        "public/pw_thread/yield.h",
138    ],
139    includes = ["public"],
140    deps = [
141        "//pw_preprocessor",
142    ],
143)
144
145pw_cc_library(
146    name = "yield",
147    srcs = [
148        "yield.cc",
149    ],
150    deps = [
151        ":id",
152        ":yield_facade",
153        "@pigweed_config//:pw_thread_yield_backend",
154    ],
155)
156
157pw_cc_library(
158    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    }),
166)
167
168pw_cc_library(
169    name = "snapshot",
170    srcs = [
171        "snapshot.cc",
172    ],
173    hdrs = [
174        "public/pw_thread/snapshot.h",
175    ],
176    deps = [
177        ":util",
178        "//pw_bytes",
179        "//pw_function",
180        "//pw_log",
181        "//pw_protobuf",
182        "//pw_status",
183        "//pw_thread:protos",
184    ],
185)
186
187pw_cc_library(
188    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 = [
206        ":id",
207        ":test_threads_header",
208        ":thread",
209        "//pw_chrono:system_clock",
210        "//pw_sync:binary_semaphore",
211        "//pw_unit_test",
212    ],
213)
214
215pw_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)
252