• 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("@rules_cc//cc:cc_library.bzl", "cc_library")
16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
17load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
18load(
19    "//pw_build:selects.bzl",
20    "TARGET_COMPATIBLE_WITH_HOST_SELECT",
21)
22load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
23
24package(
25    default_visibility = ["//visibility:public"],
26)
27
28licenses(["notice"])
29
30cc_library(
31    name = "id",
32    hdrs = [
33        "id_public_overrides/pw_thread_backend/id_inline.h",
34        "id_public_overrides/pw_thread_backend/id_native.h",
35    ],
36    strip_include_prefix = "id_public_overrides",
37    target_compatible_with = incompatible_with_mcu(),
38    deps = [
39        ":id_private",
40    ],
41)
42
43cc_library(
44    name = "id_private",
45    hdrs = [
46        "public/pw_thread_stl/id_inline.h",
47        "public/pw_thread_stl/id_native.h",
48    ],
49    strip_include_prefix = "public",
50    tags = ["noclangtidy"],
51    target_compatible_with = incompatible_with_mcu(),
52    visibility = ["//visibility:private"],
53    deps = [
54        "//pw_thread:id.facade",
55    ],
56)
57
58cc_library(
59    name = "sleep",
60    hdrs = [
61        "sleep_public_overrides/pw_thread_backend/sleep_inline.h",
62    ],
63    strip_include_prefix = "sleep_public_overrides",
64    target_compatible_with = incompatible_with_mcu(),
65    deps = [
66        ":sleep_private",
67    ],
68)
69
70cc_library(
71    name = "sleep_private",
72    hdrs = [
73        "public/pw_thread_stl/sleep_inline.h",
74    ],
75    strip_include_prefix = "public",
76    target_compatible_with = incompatible_with_mcu(),
77    visibility = ["//visibility:private"],
78    deps = [
79        "//pw_chrono:system_clock",
80        "//pw_thread:sleep.facade",
81    ],
82)
83
84cc_library(
85    name = "thread",
86    hdrs = [
87        "thread_public_overrides/pw_thread_backend/thread_inline.h",
88        "thread_public_overrides/pw_thread_backend/thread_native.h",
89    ],
90    strip_include_prefix = "thread_public_overrides",
91    target_compatible_with = incompatible_with_mcu(),
92    deps = [
93        ":thread_private",
94    ],
95)
96
97cc_library(
98    name = "thread_private",
99    hdrs = [
100        "public/pw_thread_stl/thread_inline.h",
101        "public/pw_thread_stl/thread_native.h",
102    ],
103    strip_include_prefix = "public",
104    tags = ["noclangtidy"],
105    target_compatible_with = incompatible_with_mcu(),
106    visibility = ["//visibility:private"],
107    deps = [
108        ":options",
109        "//pw_thread:thread.facade",
110    ],
111)
112
113cc_library(
114    name = "options",
115    hdrs = [
116        "public/pw_thread_stl/options.h",
117    ],
118    strip_include_prefix = "public",
119    target_compatible_with = incompatible_with_mcu(),
120    deps = [
121        "//pw_thread:options",
122    ],
123)
124
125cc_library(
126    name = "thread_creation",
127    hdrs = [
128        "thread_creation_public_overrides/pw_thread_backend/context.h",
129        "thread_creation_public_overrides/pw_thread_backend/options.h",
130        "thread_creation_public_overrides/pw_thread_backend/priority.h",
131        "thread_creation_public_overrides/pw_thread_backend/stack.h",
132    ],
133    strip_include_prefix = "thread_creation_public_overrides",
134    tags = ["noclangtidy"],
135    deps = [":options"],
136)
137
138# This target provides a stub backend for pw::this_thread::thread_iteration.
139# Iterating over child threads isn't supported by STL, so this only exists
140# for portability reasons.
141cc_library(
142    name = "thread_iteration",
143    srcs = ["thread_iteration.cc"],
144    deps = [
145        "//pw_status",
146        "//pw_thread:thread_iteration.facade",
147    ],
148)
149
150cc_library(
151    name = "non_portable_test_thread_options",
152    srcs = [
153        "test_threads.cc",
154    ],
155    target_compatible_with = incompatible_with_mcu(),
156    deps = [
157        ":options",
158        "//pw_thread:non_portable_test_thread_options",
159        "//pw_thread:thread.facade",
160    ],
161)
162
163pw_cc_test(
164    name = "thread_backend_test",
165    # TODO: b/317922402 - On Windows, this test can easily hang indefinitely.
166    # Disable on Windows until we can test with the native Windows SDK libraries
167    # for threading.
168    target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT | {
169        "@platforms//os:windows": ["@platforms//:incompatible"],
170    }),
171    deps = [
172        ":non_portable_test_thread_options",
173        "//pw_thread:thread_facade_test",
174    ],
175)
176
177cc_library(
178    name = "yield",
179    hdrs = [
180        "yield_public_overrides/pw_thread_backend/yield_inline.h",
181    ],
182    strip_include_prefix = "yield_public_overrides",
183    target_compatible_with = incompatible_with_mcu(),
184    deps = [
185        ":yield_private",
186    ],
187)
188
189cc_library(
190    name = "yield_private",
191    hdrs = [
192        "public/pw_thread_stl/yield_inline.h",
193    ],
194    strip_include_prefix = "public",
195    target_compatible_with = incompatible_with_mcu(),
196    visibility = ["//visibility:private"],
197    deps = [
198        "//pw_thread:yield.facade",
199    ],
200)
201
202cc_library(
203    name = "test_thread_context",
204    hdrs = [
205        "test_thread_context_public_overrides/pw_thread_backend/test_thread_context_native.h",
206    ],
207    strip_include_prefix = "test_thread_context_public_overrides",
208    target_compatible_with = incompatible_with_mcu(),
209    deps = [
210        ":test_thread_context_private",
211    ],
212)
213
214cc_library(
215    name = "test_thread_context_private",
216    hdrs = [
217        "public/pw_thread_stl/test_thread_context_native.h",
218    ],
219    strip_include_prefix = "public",
220    target_compatible_with = incompatible_with_mcu(),
221    visibility = ["//visibility:private"],
222    deps = [
223        ":options",
224        "//pw_thread:test_thread_context.facade",
225    ],
226)
227
228sphinx_docs_library(
229    name = "docs",
230    srcs = [
231        "docs.rst",
232        "public/pw_thread_stl/test_thread_context_native.h",
233    ],
234    prefix = "pw_thread_stl/",
235    target_compatible_with = incompatible_with_mcu(),
236)
237