blob: f7a090b1b754ffbc51e40efbe25c9cc36e8a6690 [file] [log] [blame]
Ewout van Bekkumf4da4892021-03-05 15:05:37 -08001# Copyright 2021 The Pigweed Authors
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -08002#
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
15import("//build_overrides/pigweed.gni")
16
Ewout van Bekkumf4da4892021-03-05 15:05:37 -080017import("$dir_pw_build/module_config.gni")
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -080018import("$dir_pw_build/target_types.gni")
19import("$dir_pw_chrono/backend.gni")
20import("$dir_pw_docgen/docs.gni")
21import("$dir_pw_thread/backend.gni")
Ewout van Bekkumf4da4892021-03-05 15:05:37 -080022import("$dir_pw_unit_test/test.gni")
23
24declare_args() {
25 # The build target that overrides the default configuration options for this
26 # module. This should point to a source set that provides defines through a
27 # public config (which may -include a file or add defines directly).
28 pw_thread_threadx_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
29}
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -080030
31config("public_include_path") {
32 include_dirs = [ "public" ]
33 visibility = [ ":*" ]
34}
35
36config("backend_config") {
37 include_dirs = [ "public_overrides" ]
38 visibility = [ ":*" ]
39}
40
Ewout van Bekkumf4da4892021-03-05 15:05:37 -080041pw_source_set("config") {
42 public = [ "public/pw_thread_threadx/config.h" ]
43 public_configs = [ ":public_include_path" ]
44 public_deps = [
45 "$dir_pw_third_party/threadx",
46 pw_thread_threadx_CONFIG,
47 ]
48}
49
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -080050# This target provides the backend for pw::thread::Id.
51pw_source_set("id") {
52 public_configs = [
53 ":public_include_path",
54 ":backend_config",
55 ]
56 public_deps = [
57 "$dir_pw_assert",
58 "$dir_pw_interrupt:context",
59 "$dir_pw_third_party/threadx",
60 ]
61 public = [
62 "public/pw_thread_threadx/id_inline.h",
63 "public/pw_thread_threadx/id_native.h",
64 "public_overrides/pw_thread_backend/id_inline.h",
65 "public_overrides/pw_thread_backend/id_native.h",
66 ]
67 deps = [ "$dir_pw_thread:id.facade" ]
68}
69
70if (pw_chrono_SYSTEM_CLOCK_BACKEND != "" && pw_thread_SLEEP_BACKEND != "") {
Ewout van Bekkumf4da4892021-03-05 15:05:37 -080071 # This target provides the backend for pw::this_thread::sleep_{for,until}.
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -080072 pw_source_set("sleep") {
73 public_configs = [
74 ":public_include_path",
75 ":backend_config",
76 ]
77 public = [
78 "public/pw_thread_threadx/sleep_inline.h",
79 "public_overrides/pw_thread_backend/sleep_inline.h",
80 ]
81 public_deps = [ "$dir_pw_chrono:system_clock" ]
82 sources = [ "sleep.cc" ]
83 deps = [
84 "$dir_pw_assert",
85 "$dir_pw_chrono_threadx:system_clock",
86 "$dir_pw_third_party/threadx",
87 "$dir_pw_thread:id",
88 ]
89 assert(
90 pw_thread_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
91 pw_chrono_SYSTEM_CLOCK_BACKEND ==
92 "$dir_pw_chrono_threadx:system_clock",
Ewout van Bekkumf4da4892021-03-05 15:05:37 -080093 "The ThreadX pw::this_thread::sleep_{for,until} backend only works with " + "the ThreadX pw::chrono::SystemClock backend.")
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -080094 }
95}
96
Ewout van Bekkumf4da4892021-03-05 15:05:37 -080097# This target provides the backend for pw::thread::Thread and the headers needed
98# for thread creation.
99pw_source_set("thread") {
100 public_configs = [
101 ":public_include_path",
102 ":backend_config",
103 ]
104 public_deps = [
105 ":config",
106 "$dir_pw_assert",
107 "$dir_pw_third_party/threadx",
108 "$dir_pw_thread:id",
109 "$dir_pw_thread:thread.facade",
110 ]
111 public = [
112 "public/pw_thread_threadx/context.h",
113 "public/pw_thread_threadx/options.h",
114 "public/pw_thread_threadx/thread_inline.h",
115 "public/pw_thread_threadx/thread_native.h",
116 "public_overrides/pw_thread_backend/thread_inline.h",
117 "public_overrides/pw_thread_backend/thread_native.h",
118 ]
119 allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ]
120 sources = [ "thread.cc" ]
121}
122
123# This target provides the backend for pw::this_thread::yield.
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -0800124pw_source_set("yield") {
125 public_configs = [
126 ":public_include_path",
127 ":backend_config",
128 ]
129 public = [
130 "public/pw_thread_threadx/yield_inline.h",
131 "public_overrides/pw_thread_backend/yield_inline.h",
132 ]
133 public_deps = [
134 "$dir_pw_assert",
135 "$dir_pw_third_party/threadx",
136 "$dir_pw_thread:id",
137 ]
138 deps = [ "$dir_pw_thread:yield.facade" ]
139}
140
Ewout van Bekkumf4da4892021-03-05 15:05:37 -0800141pw_test_group("tests") {
142 tests = [ ":thread_backend_test" ]
143}
144
145pw_source_set("test_threads") {
146 public_deps = [ "$dir_pw_thread:test_threads" ]
147 sources = [ "test_threads.cc" ]
148 deps = [
149 "$dir_pw_chrono:system_clock",
150 "$dir_pw_thread:sleep",
151 "$dir_pw_thread:thread",
152 dir_pw_assert,
153 dir_pw_log,
154 ]
155}
156
157pw_test("thread_backend_test") {
158 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_threadx:thread"
159 deps = [
160 ":test_threads",
161 "$dir_pw_thread:thread_facade_test",
162 ]
163}
164
Ewout van Bekkumfe5b4a72021-02-01 17:03:58 -0800165pw_doc_group("docs") {
166 sources = [ "docs.rst" ]
167}