Ewout van Bekkum | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 1 | # Copyright 2021 The Pigweed Authors |
Ewout van Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -0800 | [diff] [blame] | 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 | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 17 | import("$dir_pw_build/module_config.gni") |
Ewout van Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -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 | f4da489 | 2021-03-05 15:05:37 -0800 | [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_threadx_CONFIG = pw_build_DEFAULT_MODULE_CONFIG |
| 29 | } |
Ewout van Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -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 | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 41 | pw_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 Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -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/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 | |
| 70 | if (pw_chrono_SYSTEM_CLOCK_BACKEND != "" && pw_thread_SLEEP_BACKEND != "") { |
Ewout van Bekkum | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 71 | # This target provides the backend for pw::this_thread::sleep_{for,until}. |
Ewout van Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -0800 | [diff] [blame] | 72 | 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 Bekkum | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 93 | "The ThreadX pw::this_thread::sleep_{for,until} backend only works with " + "the ThreadX pw::chrono::SystemClock backend.") |
Ewout van Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -0800 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
Ewout van Bekkum | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 97 | # This target provides the backend for pw::thread::Thread and the headers needed |
| 98 | # for thread creation. |
| 99 | pw_source_set("thread") { |
| 100 | public_configs = [ |
| 101 | ":public_include_path", |
| 102 | ":backend_config", |
| 103 | ] |
| 104 | public_deps = [ |
| 105 | ":config", |
| 106 | "$dir_pw_assert", |
Ewout van Bekkum | cd765c0 | 2021-05-14 10:28:26 -0700 | [diff] [blame] | 107 | "$dir_pw_string", |
Ewout van Bekkum | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 108 | "$dir_pw_third_party/threadx", |
| 109 | "$dir_pw_thread:id", |
| 110 | "$dir_pw_thread:thread.facade", |
| 111 | ] |
| 112 | public = [ |
| 113 | "public/pw_thread_threadx/context.h", |
| 114 | "public/pw_thread_threadx/options.h", |
| 115 | "public/pw_thread_threadx/thread_inline.h", |
| 116 | "public/pw_thread_threadx/thread_native.h", |
| 117 | "public_overrides/pw_thread_backend/thread_inline.h", |
| 118 | "public_overrides/pw_thread_backend/thread_native.h", |
| 119 | ] |
| 120 | allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ] |
| 121 | sources = [ "thread.cc" ] |
| 122 | } |
| 123 | |
| 124 | # This target provides the backend for pw::this_thread::yield. |
Ewout van Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -0800 | [diff] [blame] | 125 | pw_source_set("yield") { |
| 126 | public_configs = [ |
| 127 | ":public_include_path", |
| 128 | ":backend_config", |
| 129 | ] |
| 130 | public = [ |
| 131 | "public/pw_thread_threadx/yield_inline.h", |
| 132 | "public_overrides/pw_thread_backend/yield_inline.h", |
| 133 | ] |
| 134 | public_deps = [ |
| 135 | "$dir_pw_assert", |
| 136 | "$dir_pw_third_party/threadx", |
| 137 | "$dir_pw_thread:id", |
| 138 | ] |
| 139 | deps = [ "$dir_pw_thread:yield.facade" ] |
| 140 | } |
| 141 | |
Ewout van Bekkum | f4da489 | 2021-03-05 15:05:37 -0800 | [diff] [blame] | 142 | pw_test_group("tests") { |
| 143 | tests = [ ":thread_backend_test" ] |
| 144 | } |
| 145 | |
| 146 | pw_source_set("test_threads") { |
| 147 | public_deps = [ "$dir_pw_thread:test_threads" ] |
| 148 | sources = [ "test_threads.cc" ] |
| 149 | deps = [ |
| 150 | "$dir_pw_chrono:system_clock", |
| 151 | "$dir_pw_thread:sleep", |
| 152 | "$dir_pw_thread:thread", |
| 153 | dir_pw_assert, |
| 154 | dir_pw_log, |
| 155 | ] |
| 156 | } |
| 157 | |
| 158 | pw_test("thread_backend_test") { |
| 159 | enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_threadx:thread" |
| 160 | deps = [ |
| 161 | ":test_threads", |
| 162 | "$dir_pw_thread:thread_facade_test", |
| 163 | ] |
| 164 | } |
| 165 | |
Ewout van Bekkum | fe5b4a7 | 2021-02-01 17:03:58 -0800 | [diff] [blame] | 166 | pw_doc_group("docs") { |
| 167 | sources = [ "docs.rst" ] |
| 168 | } |