• 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("@bazel_skylib//rules:run_binary.bzl", "run_binary")
16load(
17    "//pw_build:pigweed.bzl",
18    "pw_cc_test",
19)
20
21package(default_visibility = ["//visibility:public"])
22
23licenses(["notice"])
24
25cc_library(
26    name = "id",
27    hdrs = [
28        "id_public_overrides/pw_thread_backend/id_inline.h",
29        "id_public_overrides/pw_thread_backend/id_native.h",
30        "public/pw_thread_freertos/id_inline.h",
31        "public/pw_thread_freertos/id_native.h",
32    ],
33    includes = [
34        "id_public_overrides",
35        "public",
36    ],
37    target_compatible_with = [
38        "//pw_build/constraints/rtos:freertos",
39    ],
40    deps = [
41        "//pw_interrupt:context",
42        "//pw_thread:id.facade",
43        "@freertos",
44    ],
45)
46
47cc_library(
48    name = "sleep",
49    srcs = [
50        "sleep.cc",
51    ],
52    hdrs = [
53        "public/pw_thread_freertos/sleep_inline.h",
54        "sleep_public_overrides/pw_thread_backend/sleep_inline.h",
55    ],
56    includes = [
57        "public",
58        "sleep_public_overrides",
59    ],
60    target_compatible_with = [
61        "//pw_build/constraints/rtos:freertos",
62    ],
63    deps = [
64        "//pw_assert",
65        "//pw_chrono:system_clock",
66        "//pw_thread:id",
67        "//pw_thread:sleep.facade",
68        "@freertos",
69    ],
70)
71
72cc_library(
73    name = "thread",
74    srcs = [
75        "thread.cc",
76    ],
77    hdrs = [
78        "public/pw_thread_freertos/config.h",
79        "public/pw_thread_freertos/context.h",
80        "public/pw_thread_freertos/options.h",
81        "public/pw_thread_freertos/thread_inline.h",
82        "public/pw_thread_freertos/thread_native.h",
83        "thread_public_overrides/pw_thread_backend/thread_inline.h",
84        "thread_public_overrides/pw_thread_backend/thread_native.h",
85    ],
86    includes = [
87        "public",
88        "thread_public_overrides",
89    ],
90    target_compatible_with = [
91        "//pw_build/constraints/rtos:freertos",
92    ],
93    deps = [
94        ":config_override",
95        ":id",
96        "//pw_assert",
97        "//pw_string",
98        "//pw_sync:binary_semaphore",
99        "//pw_thread:deprecated_or_new_thread_function",
100        "//pw_thread:thread.facade",
101    ],
102)
103
104label_flag(
105    name = "config_override",
106    build_setting_default = "//pw_build:default_module_config",
107)
108
109cc_library(
110    name = "dynamic_test_threads",
111    srcs = [
112        "dynamic_test_threads.cc",
113    ],
114    target_compatible_with = [
115        "//pw_build/constraints/rtos:freertos",
116    ],
117    deps = [
118        "//pw_chrono:system_clock",
119        "//pw_thread:non_portable_test_thread_options",
120        "//pw_thread:sleep",
121        "//pw_thread:thread.facade",
122    ],
123)
124
125pw_cc_test(
126    name = "dynamic_thread_backend_test",
127    # TODO: b/271465588 - Get this test to build.
128    tags = ["manual"],
129    deps = [
130        ":dynamic_test_threads",
131        "//pw_thread:thread_facade_test",
132    ],
133)
134
135cc_library(
136    name = "static_test_threads",
137    srcs = [
138        "static_test_threads.cc",
139    ],
140    target_compatible_with = [
141        "//pw_build/constraints/rtos:freertos",
142    ],
143    deps = [
144        "//pw_chrono:system_clock",
145        "//pw_thread:non_portable_test_thread_options",
146        "//pw_thread:sleep",
147        "//pw_thread:thread.facade",
148    ],
149)
150
151pw_cc_test(
152    name = "static_thread_backend_test",
153    # TODO: b/271465588 - Get this test to build.
154    tags = ["manual"],
155    deps = [
156        ":static_test_threads",
157        "//pw_thread:thread_facade_test",
158    ],
159)
160
161cc_library(
162    name = "yield",
163    hdrs = [
164        "public/pw_thread_freertos/yield_inline.h",
165        "yield_public_overrides/pw_thread_backend/yield_inline.h",
166    ],
167    includes = [
168        "public",
169        "yield_public_overrides",
170    ],
171    deps = [
172        "//pw_thread:yield.facade",
173        "@freertos",
174    ],
175)
176
177cc_library(
178    name = "thread_iteration",
179    srcs = [
180        "pw_thread_freertos_private/thread_iteration.h",
181        "thread_iteration.cc",
182    ],
183    target_compatible_with = [
184        "//pw_build/constraints/rtos:freertos",
185    ],
186    deps = [
187        ":freertos_tasktcb",
188        "//pw_function",
189        "//pw_span",
190        "//pw_status",
191        "//pw_thread:thread_info",
192        "//pw_thread:thread_iteration.facade",
193        "//pw_thread_freertos:util",
194    ],
195)
196
197pw_cc_test(
198    name = "thread_iteration_test",
199    srcs = [
200        "pw_thread_freertos_private/thread_iteration.h",
201        "thread_iteration_test.cc",
202    ],
203    # TODO: b/271465588 - Get this test to build.
204    tags = ["manual"],
205    deps = [
206        ":freertos_tasktcb",
207        ":static_test_threads",
208        ":thread_iteration",
209        "//pw_bytes",
210        "//pw_span",
211        "//pw_string:builder",
212        "//pw_string:util",
213        "//pw_sync:thread_notification",
214        "//pw_thread:non_portable_test_thread_options",
215        "//pw_thread:thread",
216        "//pw_thread:thread_info",
217        "//pw_thread:thread_iteration",
218    ],
219)
220
221cc_library(
222    name = "util",
223    srcs = [
224        "util.cc",
225    ],
226    hdrs = [
227        "public/pw_thread_freertos/util.h",
228    ],
229    includes = ["public"],
230    target_compatible_with = [
231        "//pw_build/constraints/rtos:freertos",
232    ],
233    deps = [
234        "//pw_function",
235        "//pw_log",
236        "//pw_span",
237        "//pw_status",
238        "@freertos",
239    ],
240)
241
242cc_library(
243    name = "snapshot",
244    srcs = [
245        "snapshot.cc",
246    ],
247    hdrs = [
248        "public/pw_thread_freertos/snapshot.h",
249    ],
250    # TODO: b/269204725 - Put this in the toolchain configuration instead.  I
251    # would like to say `copts = ["-Wno-c++20-designator"]`, but arm-gcc tells
252    # me that's an "unrecognized command line option"; I think it may be a
253    # clang-only flag.
254    copts = ["-Wno-pedantic"],
255    target_compatible_with = [
256        "//pw_build/constraints/rtos:freertos",
257    ],
258    deps = [
259        ":freertos_tasktcb",
260        ":util",
261        "//pw_function",
262        "//pw_log",
263        "//pw_protobuf",
264        "//pw_status",
265        "//pw_thread:snapshot",
266        "//pw_thread:thread_cc.pwpb",
267    ],
268)
269
270cc_library(
271    name = "freertos_tasktcb",
272    hdrs = [
273        "public/pw_thread_freertos/freertos_tsktcb.h",
274        ":generate_freertos_tsktcb",
275    ],
276    includes = [
277        "public",
278        "thread_public_overrides",
279    ],
280)
281
282run_binary(
283    name = "generate_freertos_tsktcb",
284    srcs = [
285        "@freertos//:tasks.c",
286    ],
287    outs = [":thread_public_overrides/pw_thread_freertos_backend/freertos_tsktcb.h"],
288    args = [
289        "--freertos-tasks-c=$(location @freertos//:tasks.c)",
290        "--output=$(location :thread_public_overrides/pw_thread_freertos_backend/freertos_tsktcb.h)",
291    ],
292    tool = "//pw_thread_freertos/py:generate_freertos_tsktcb",
293)
294