blob: 383b6a68156c5be8635c5f79e7845dcb7d346ee4 [file] [log] [blame]
Ewout van Bekkum8b72a572021-03-09 08:53:39 -08001# Copyright 2021 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 Bekkum6e5d43e2021-05-06 15:29:44 -070017import("$dir_pw_build/module_config.gni")
Ewout van Bekkum8b72a572021-03-09 08:53:39 -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 Bekkum6e5d43e2021-05-06 15:29:44 -070022import("$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_embos_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
29}
Ewout van Bekkum8b72a572021-03-09 08:53:39 -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 Bekkum6e5d43e2021-05-06 15:29:44 -070041pw_source_set("config") {
42 public = [ "public/pw_thread_embos/config.h" ]
43 public_configs = [ ":public_include_path" ]
44 public_deps = [
45 "$dir_pw_third_party/embos",
46 pw_thread_embos_CONFIG,
47 ]
48}
49
Ewout van Bekkum8b72a572021-03-09 08:53:39 -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/embos",
60 ]
61 public = [
62 "public/pw_thread_embos/id_inline.h",
63 "public/pw_thread_embos/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 != "") {
71 # This target provides the backend for pw::thread::sleep_{for,until}.
72 pw_source_set("sleep") {
73 public_configs = [
74 ":public_include_path",
75 ":backend_config",
76 ]
77 public = [
78 "public/pw_thread_embos/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_embos:system_clock",
86 "$dir_pw_third_party/embos",
87 "$dir_pw_thread:id",
88 "$dir_pw_thread:sleep.facade",
89 ]
90 assert(pw_thread_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
91 pw_chrono_SYSTEM_CLOCK_BACKEND ==
92 "$dir_pw_chrono_embos:system_clock",
93 "The embOS pw::thread::sleep_{for,until} backend only works with " +
94 "the embOS pw::chrono::SystemClock backend.")
95 }
96}
97
Ewout van Bekkum6e5d43e2021-05-06 15:29:44 -070098# This target provides the backend for pw::thread::Thread and the headers needed
99# for thread creation.
100pw_source_set("thread") {
101 public_configs = [
102 ":public_include_path",
103 ":backend_config",
104 ]
105 public_deps = [
106 ":config",
107 "$dir_pw_assert",
108 "$dir_pw_string",
109 "$dir_pw_third_party/embos",
110 "$dir_pw_thread:id",
111 "$dir_pw_thread:thread.facade",
112 ]
113 public = [
114 "public/pw_thread_embos/context.h",
115 "public/pw_thread_embos/options.h",
116 "public/pw_thread_embos/thread_inline.h",
117 "public/pw_thread_embos/thread_native.h",
118 "public_overrides/pw_thread_backend/thread_inline.h",
119 "public_overrides/pw_thread_backend/thread_native.h",
120 ]
121 allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ]
122 sources = [ "thread.cc" ]
123}
124
Ewout van Bekkum8b72a572021-03-09 08:53:39 -0800125# This target provides the backend for pw::thread::yield.
126pw_source_set("yield") {
127 public_configs = [
128 ":public_include_path",
129 ":backend_config",
130 ]
131 public = [
132 "public/pw_thread_embos/yield_inline.h",
133 "public_overrides/pw_thread_backend/yield_inline.h",
134 ]
135 public_deps = [
136 "$dir_pw_assert",
137 "$dir_pw_third_party/embos",
138 "$dir_pw_thread:id",
139 ]
140 deps = [ "$dir_pw_thread:yield.facade" ]
141}
142
Ewout van Bekkum6e5d43e2021-05-06 15:29:44 -0700143pw_test_group("tests") {
144 tests = [ ":thread_backend_test" ]
145}
146
147pw_source_set("test_threads") {
148 public_deps = [ "$dir_pw_thread:test_threads" ]
149 sources = [ "test_threads.cc" ]
150 deps = [
151 "$dir_pw_chrono:system_clock",
152 "$dir_pw_thread:sleep",
153 "$dir_pw_thread:thread",
154 dir_pw_assert,
155 dir_pw_log,
156 ]
157}
158
159pw_test("thread_backend_test") {
160 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_embos:thread"
161 deps = [
162 ":test_threads",
163 "$dir_pw_thread:thread_facade_test",
164 ]
165}
166
Ewout van Bekkum8b72a572021-03-09 08:53:39 -0800167pw_doc_group("docs") {
168 sources = [ "docs.rst" ]
169}