blob: 7071804d29366cf9be2248cc4cdefa2a1f8827a2 [file] [log] [blame]
Ewout van Bekkum749342b2021-01-19 14:53:19 -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
15import("//build_overrides/pigweed.gni")
16
Ewout van Bekkumae6c03a2021-01-19 14:53:19 -080017import("$dir_pw_build/module_config.gni")
Ewout van Bekkum749342b2021-01-19 14:53:19 -080018import("$dir_pw_build/target_types.gni")
19import("$dir_pw_chrono/backend.gni")
20import("$dir_pw_docgen/docs.gni")
Ewout van Bekkumae6c03a2021-01-19 14:53:19 -080021import("$dir_pw_thread/backend.gni")
22import("$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_freertos_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
29}
Ewout van Bekkum749342b2021-01-19 14:53:19 -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 Bekkumae6c03a2021-01-19 14:53:19 -080041pw_source_set("config") {
42 public = [ "public/pw_thread_freertos/config.h" ]
43 public_configs = [ ":public_include_path" ]
44 public_deps = [
45 "$dir_pw_third_party/freertos",
46 pw_thread_freertos_CONFIG,
47 ]
48}
49
Ewout van Bekkum749342b2021-01-19 14:53:19 -080050# This target provides the backend for pw::thread::Id & pw::this_thread::get_id.
51pw_source_set("id") {
52 public_configs = [
53 ":public_include_path",
54 ":backend_config",
55 ]
56 public_deps = [
57 "$dir_pw_interrupt:context",
58 "$dir_pw_third_party/freertos",
59 ]
60 public = [
61 "public/pw_thread_freertos/id_inline.h",
62 "public/pw_thread_freertos/id_native.h",
63 "public_overrides/pw_thread_backend/id_inline.h",
64 "public_overrides/pw_thread_backend/id_native.h",
65 ]
66 deps = [ "$dir_pw_thread:id.facade" ]
67}
68
69# This target provides the backend for pw::this_thread::sleep_{for,until}.
70pw_source_set("sleep") {
71 public_configs = [
72 ":public_include_path",
73 ":backend_config",
74 ]
75 public = [
76 "public/pw_thread_freertos/sleep_inline.h",
77 "public_overrides/pw_thread_backend/sleep_inline.h",
78 ]
79 public_deps = [ "$dir_pw_chrono:system_clock" ]
80 sources = [ "sleep.cc" ]
81 deps = [
82 "$dir_pw_assert",
83 "$dir_pw_chrono_freertos:system_clock",
84 "$dir_pw_third_party/freertos",
85 "$dir_pw_thread:id",
86 "$dir_pw_thread:sleep.facade",
87 ]
88 assert(pw_chrono_SYSTEM_CLOCK_BACKEND == "" ||
89 pw_chrono_SYSTEM_CLOCK_BACKEND ==
90 "$dir_pw_chrono_freertos:system_clock",
91 "The FreeRTOS pw::this_thread::sleep_{for,until} backend only works " +
92 "with the FreeRTOS pw::chrono::SystemClock backend " +
93 "(pw_chrono_SYSTEM_CLOCK_BACKEND = " +
94 "\"$dir_pw_chrono_freertos:system_clock\")")
95}
96
Ewout van Bekkumae6c03a2021-01-19 14:53:19 -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/freertos",
108 "$dir_pw_thread:id",
109 "$dir_pw_thread:thread.facade",
110 ]
111 public = [
112 "public/pw_thread_freertos/context.h",
113 "public/pw_thread_freertos/options.h",
114 "public/pw_thread_freertos/thread_inline.h",
115 "public/pw_thread_freertos/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
Ewout van Bekkum749342b2021-01-19 14:53:19 -0800123# This target provides the backend for pw::this_thread::yield.
124pw_source_set("yield") {
125 public_configs = [
126 ":public_include_path",
127 ":backend_config",
128 ]
129 public = [
130 "public/pw_thread_freertos/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/freertos",
136 "$dir_pw_thread:id",
137 ]
138 deps = [ "$dir_pw_thread:yield.facade" ]
139}
140
Ewout van Bekkumae6c03a2021-01-19 14:53:19 -0800141pw_test_group("tests") {
142 tests = [
143 ":dynamic_thread_backend_test",
144 ":static_thread_backend_test",
145 ]
146}
147
148pw_source_set("dynamic_test_threads") {
149 public_deps = [ "$dir_pw_thread:test_threads" ]
150 sources = [ "dynamic_test_threads.cc" ]
151 deps = [
152 "$dir_pw_chrono:system_clock",
153 "$dir_pw_thread:sleep",
154 "$dir_pw_thread:thread",
155 ]
156}
157
158pw_test("dynamic_thread_backend_test") {
159 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_freertos:thread"
160 deps = [
161 ":dynamic_test_threads",
162 "$dir_pw_thread:thread_facade_test",
163 ]
164}
165
166pw_source_set("static_test_threads") {
167 public_deps = [ "$dir_pw_thread:test_threads" ]
168 sources = [ "static_test_threads.cc" ]
169 deps = [
170 "$dir_pw_chrono:system_clock",
171 "$dir_pw_thread:sleep",
172 "$dir_pw_thread:thread",
173 ]
174}
175
176pw_test("static_thread_backend_test") {
177 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_freertos:thread"
178 deps = [
179 ":static_test_threads",
180 "$dir_pw_thread:thread_facade_test",
181 ]
182}
183
Ewout van Bekkum749342b2021-01-19 14:53:19 -0800184pw_doc_group("docs") {
185 sources = [ "docs.rst" ]
186}