Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 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 | |
| 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_build/facade.gni") |
Armando Montanez | 5f10ff8 | 2021-08-13 13:47:39 -0700 | [diff] [blame] | 18 | import("$dir_pw_build/module_config.gni") |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 19 | import("$dir_pw_build/target_types.gni") |
| 20 | import("$dir_pw_docgen/docs.gni") |
Armando Montanez | 179aa8e | 2021-03-10 11:46:35 -0800 | [diff] [blame] | 21 | import("$dir_pw_protobuf_compiler/proto.gni") |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 22 | import("$dir_pw_unit_test/test.gni") |
| 23 | import("backend.gni") |
| 24 | |
Armando Montanez | 5f10ff8 | 2021-08-13 13:47:39 -0700 | [diff] [blame] | 25 | declare_args() { |
| 26 | # The build target that overrides the default configuration options for this |
| 27 | # module. This should point to a source set that provides defines through a |
| 28 | # public config (which may -include a file or add defines directly). |
| 29 | pw_thread_CONFIG = pw_build_DEFAULT_MODULE_CONFIG |
| 30 | } |
| 31 | |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 32 | config("public_include_path") { |
| 33 | include_dirs = [ "public" ] |
| 34 | visibility = [ ":*" ] |
| 35 | } |
| 36 | |
Armando Montanez | 5f10ff8 | 2021-08-13 13:47:39 -0700 | [diff] [blame] | 37 | pw_source_set("config") { |
| 38 | public_deps = [ pw_thread_CONFIG ] |
| 39 | public = [ "public/pw_thread/config.h" ] |
| 40 | public_configs = [ ":public_include_path" ] |
| 41 | visibility = [ ":*" ] |
| 42 | } |
| 43 | |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 44 | pw_facade("id") { |
| 45 | backend = pw_thread_ID_BACKEND |
| 46 | public_configs = [ ":public_include_path" ] |
| 47 | public = [ "public/pw_thread/id.h" ] |
| 48 | } |
| 49 | |
| 50 | pw_facade("sleep") { |
| 51 | backend = pw_thread_SLEEP_BACKEND |
| 52 | public_configs = [ ":public_include_path" ] |
| 53 | public = [ "public/pw_thread/sleep.h" ] |
| 54 | public_deps = [ |
| 55 | "$dir_pw_chrono:system_clock", |
| 56 | "$dir_pw_preprocessor", |
| 57 | ] |
| 58 | sources = [ "sleep.cc" ] |
| 59 | } |
| 60 | |
Ewout van Bekkum | 0f3901e | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 61 | pw_facade("thread") { |
| 62 | backend = pw_thread_THREAD_BACKEND |
| 63 | public_configs = [ ":public_include_path" ] |
Ewout van Bekkum | 19e753a | 2021-04-28 18:06:55 -0700 | [diff] [blame] | 64 | public = [ |
| 65 | "public/pw_thread/detached_thread.h", |
| 66 | "public/pw_thread/thread.h", |
| 67 | ] |
Ewout van Bekkum | a082d7f | 2021-04-15 14:36:37 -0700 | [diff] [blame] | 68 | public_deps = [ |
| 69 | ":id", |
| 70 | ":thread_core", |
| 71 | ] |
| 72 | sources = [ "thread.cc" ] |
| 73 | } |
| 74 | |
| 75 | pw_source_set("thread_core") { |
| 76 | public_configs = [ ":public_include_path" ] |
| 77 | public = [ "public/pw_thread/thread_core.h" ] |
Ewout van Bekkum | 0f3901e | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 80 | pw_facade("yield") { |
| 81 | backend = pw_thread_YIELD_BACKEND |
| 82 | public_configs = [ ":public_include_path" ] |
| 83 | public = [ "public/pw_thread/yield.h" ] |
| 84 | public_deps = [ "$dir_pw_preprocessor" ] |
| 85 | sources = [ "yield.cc" ] |
| 86 | } |
| 87 | |
Armando Montanez | fec572b | 2021-06-28 12:13:57 -0700 | [diff] [blame] | 88 | pw_source_set("snapshot") { |
| 89 | public_configs = [ ":public_include_path" ] |
| 90 | public_deps = [ |
| 91 | "$dir_pw_thread:protos.pwpb", |
| 92 | dir_pw_bytes, |
| 93 | dir_pw_function, |
| 94 | dir_pw_protobuf, |
| 95 | dir_pw_status, |
| 96 | ] |
| 97 | public = [ "public/pw_thread/snapshot.h" ] |
| 98 | sources = [ "snapshot.cc" ] |
Armando Montanez | 5f10ff8 | 2021-08-13 13:47:39 -0700 | [diff] [blame] | 99 | deps = [ |
| 100 | ":config", |
| 101 | dir_pw_log, |
| 102 | ] |
Armando Montanez | fec572b | 2021-06-28 12:13:57 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 105 | pw_test_group("tests") { |
| 106 | tests = [ |
| 107 | ":id_facade_test", |
| 108 | ":sleep_facade_test", |
| 109 | ":yield_facade_test", |
| 110 | ] |
| 111 | } |
| 112 | |
| 113 | pw_test("id_facade_test") { |
| 114 | enable_if = pw_thread_ID_BACKEND != "" |
| 115 | sources = [ "id_facade_test.cc" ] |
| 116 | deps = [ ":id" ] |
| 117 | } |
| 118 | |
| 119 | pw_test("sleep_facade_test") { |
| 120 | enable_if = pw_thread_SLEEP_BACKEND != "" && pw_thread_ID_BACKEND != "" |
| 121 | sources = [ |
| 122 | "sleep_facade_test.cc", |
| 123 | "sleep_facade_test_c.c", |
| 124 | ] |
| 125 | deps = [ |
| 126 | ":id", |
| 127 | ":sleep", |
| 128 | "$dir_pw_chrono:system_clock", |
| 129 | ] |
| 130 | } |
| 131 | |
Rob Mohr | 4663d47 | 2021-09-08 11:29:07 -0700 | [diff] [blame] | 132 | pw_source_set("test_threads") { |
| 133 | public_configs = [ ":public_include_path" ] |
| 134 | public = [ "public/pw_thread/test_threads.h" ] |
| 135 | public_deps = [ ":thread" ] |
| 136 | } |
Ewout van Bekkum | 0f3901e | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 137 | |
Rob Mohr | 4663d47 | 2021-09-08 11:29:07 -0700 | [diff] [blame] | 138 | # To instantiate this facade test based on a selected backend to provide |
| 139 | # test_threads you can create a pw_test target which depends on this |
| 140 | # pw_source_set and a pw_source_set which provides the implementation of |
| 141 | # test_threads. See "$dir_pw_thread_stl:thread_backend_test" as an example. |
| 142 | pw_source_set("thread_facade_test") { |
| 143 | sources = [ "thread_facade_test.cc" ] |
| 144 | deps = [ |
| 145 | ":id", |
| 146 | ":sleep", |
| 147 | ":test_threads", |
| 148 | ":thread", |
| 149 | "$dir_pw_sync:binary_semaphore", |
| 150 | dir_pw_unit_test, |
| 151 | ] |
Ewout van Bekkum | 0f3901e | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 152 | } |
| 153 | |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 154 | pw_test("yield_facade_test") { |
| 155 | enable_if = pw_thread_YIELD_BACKEND != "" && pw_thread_ID_BACKEND != "" |
| 156 | sources = [ |
| 157 | "yield_facade_test.cc", |
| 158 | "yield_facade_test_c.c", |
| 159 | ] |
| 160 | deps = [ |
| 161 | ":id", |
| 162 | ":yield", |
| 163 | ] |
| 164 | } |
| 165 | |
Armando Montanez | 179aa8e | 2021-03-10 11:46:35 -0800 | [diff] [blame] | 166 | pw_proto_library("protos") { |
| 167 | sources = [ "pw_thread_protos/thread.proto" ] |
Armando Montanez | 8931430 | 2021-07-28 10:32:53 -0700 | [diff] [blame] | 168 | deps = [ "$dir_pw_tokenizer:proto" ] |
Armando Montanez | 179aa8e | 2021-03-10 11:46:35 -0800 | [diff] [blame] | 169 | } |
| 170 | |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 171 | pw_doc_group("docs") { |
| 172 | sources = [ "docs.rst" ] |
| 173 | } |