Ewout van Bekkum | 8b72a57 | 2021-03-09 08:53:39 -0800 | [diff] [blame] | 1 | # 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 | |
| 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
Ewout van Bekkum | 6e5d43e | 2021-05-06 15:29:44 -0700 | [diff] [blame^] | 17 | import("$dir_pw_build/module_config.gni") |
Ewout van Bekkum | 8b72a57 | 2021-03-09 08:53:39 -0800 | [diff] [blame] | 18 | import("$dir_pw_build/target_types.gni") |
| 19 | import("$dir_pw_chrono/backend.gni") |
| 20 | import("$dir_pw_docgen/docs.gni") |
| 21 | import("$dir_pw_thread/backend.gni") |
Ewout van Bekkum | 6e5d43e | 2021-05-06 15:29:44 -0700 | [diff] [blame^] | 22 | import("$dir_pw_unit_test/test.gni") |
| 23 | |
| 24 | declare_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 Bekkum | 8b72a57 | 2021-03-09 08:53:39 -0800 | [diff] [blame] | 30 | |
| 31 | config("public_include_path") { |
| 32 | include_dirs = [ "public" ] |
| 33 | visibility = [ ":*" ] |
| 34 | } |
| 35 | |
| 36 | config("backend_config") { |
| 37 | include_dirs = [ "public_overrides" ] |
| 38 | visibility = [ ":*" ] |
| 39 | } |
| 40 | |
Ewout van Bekkum | 6e5d43e | 2021-05-06 15:29:44 -0700 | [diff] [blame^] | 41 | pw_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 Bekkum | 8b72a57 | 2021-03-09 08:53:39 -0800 | [diff] [blame] | 50 | # This target provides the backend for pw::thread::Id. |
| 51 | pw_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 | |
| 70 | if (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 Bekkum | 6e5d43e | 2021-05-06 15:29:44 -0700 | [diff] [blame^] | 98 | # This target provides the backend for pw::thread::Thread and the headers needed |
| 99 | # for thread creation. |
| 100 | pw_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 Bekkum | 8b72a57 | 2021-03-09 08:53:39 -0800 | [diff] [blame] | 125 | # This target provides the backend for pw::thread::yield. |
| 126 | pw_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 Bekkum | 6e5d43e | 2021-05-06 15:29:44 -0700 | [diff] [blame^] | 143 | pw_test_group("tests") { |
| 144 | tests = [ ":thread_backend_test" ] |
| 145 | } |
| 146 | |
| 147 | pw_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 | |
| 159 | pw_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 Bekkum | 8b72a57 | 2021-03-09 08:53:39 -0800 | [diff] [blame] | 167 | pw_doc_group("docs") { |
| 168 | sources = [ "docs.rst" ] |
| 169 | } |