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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/error.gni") 18import("$dir_pw_build/module_config.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_chrono/backend.gni") 21import("$dir_pw_docgen/docs.gni") 22import("$dir_pw_thread/backend.gni") 23import("$dir_pw_unit_test/test.gni") 24 25declare_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_embos_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 30} 31 32config("public_include_path") { 33 include_dirs = [ "public" ] 34 visibility = [ ":*" ] 35} 36 37config("id_public_overrides") { 38 include_dirs = [ "id_public_overrides" ] 39 visibility = [ ":*" ] 40} 41 42pw_source_set("config") { 43 public = [ "public/pw_thread_embos/config.h" ] 44 public_configs = [ ":public_include_path" ] 45 public_deps = [ 46 "$dir_pw_third_party/embos", 47 pw_thread_embos_CONFIG, 48 ] 49} 50 51# This target provides the backend for pw::Thread::id. 52pw_source_set("id") { 53 public_configs = [ 54 ":public_include_path", 55 ":id_public_overrides", 56 ] 57 public_deps = [ 58 "$dir_pw_assert", 59 "$dir_pw_interrupt:context", 60 "$dir_pw_third_party/embos", 61 ] 62 public = [ 63 "id_public_overrides/pw_thread_backend/id_inline.h", 64 "id_public_overrides/pw_thread_backend/id_native.h", 65 "public/pw_thread_embos/id_inline.h", 66 "public/pw_thread_embos/id_native.h", 67 ] 68 deps = [ "$dir_pw_thread:id.facade" ] 69} 70 71pw_build_assert("check_system_clock_backend") { 72 condition = 73 pw_thread_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK || 74 pw_chrono_SYSTEM_CLOCK_BACKEND == "$dir_pw_chrono_embos:system_clock" 75 message = "The embOS pw::thread::sleep_{for,until} backend only works with " + 76 "the embOS pw::chrono::SystemClock backend." 77 visibility = [ ":*" ] 78} 79 80if (pw_chrono_SYSTEM_CLOCK_BACKEND != "" && pw_thread_SLEEP_BACKEND != "") { 81 config("sleep_public_overrides") { 82 include_dirs = [ "sleep_public_overrides" ] 83 visibility = [ ":*" ] 84 } 85 86 # This target provides the backend for pw::thread::sleep_{for,until}. 87 pw_source_set("sleep") { 88 public_configs = [ 89 ":public_include_path", 90 ":sleep_public_overrides", 91 ] 92 public = [ 93 "public/pw_thread_embos/sleep_inline.h", 94 "sleep_public_overrides/pw_thread_backend/sleep_inline.h", 95 ] 96 public_deps = [ "$dir_pw_chrono:system_clock" ] 97 sources = [ "sleep.cc" ] 98 deps = [ 99 ":check_system_clock_backend", 100 "$dir_pw_assert", 101 "$dir_pw_chrono_embos:system_clock", 102 "$dir_pw_third_party/embos", 103 "$dir_pw_thread:sleep.facade", 104 "$dir_pw_thread:thread", 105 ] 106 } 107} 108 109config("thread_public_overrides") { 110 include_dirs = [ "thread_public_overrides" ] 111 visibility = [ ":*" ] 112} 113 114# This target provides the backend for pw::Thread and the headers needed for 115# thread creation. 116pw_source_set("thread") { 117 public_configs = [ 118 ":public_include_path", 119 ":thread_public_overrides", 120 ] 121 public_deps = [ 122 ":config", 123 "$dir_pw_assert", 124 "$dir_pw_string", 125 "$dir_pw_third_party/embos", 126 "$dir_pw_thread:id", 127 "$dir_pw_thread:thread.facade", 128 dir_pw_function, 129 dir_pw_span, 130 ] 131 public = [ 132 "public/pw_thread_embos/context.h", 133 "public/pw_thread_embos/options.h", 134 "public/pw_thread_embos/thread_inline.h", 135 "public/pw_thread_embos/thread_native.h", 136 "thread_public_overrides/pw_thread_backend/thread_inline.h", 137 "thread_public_overrides/pw_thread_backend/thread_native.h", 138 ] 139 allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ] 140 sources = [ "thread.cc" ] 141} 142 143config("yield_public_overrides") { 144 include_dirs = [ "yield_public_overrides" ] 145 visibility = [ ":*" ] 146} 147 148# This target provides the backend for pw::thread::yield. 149pw_source_set("yield") { 150 public_configs = [ 151 ":public_include_path", 152 ":yield_public_overrides", 153 ] 154 public = [ 155 "public/pw_thread_embos/yield_inline.h", 156 "yield_public_overrides/pw_thread_backend/yield_inline.h", 157 ] 158 public_deps = [ 159 "$dir_pw_assert", 160 "$dir_pw_third_party/embos", 161 "$dir_pw_thread:thread", 162 ] 163 deps = [ "$dir_pw_thread:yield.facade" ] 164} 165 166pw_source_set("util") { 167 public_configs = [ ":public_include_path" ] 168 public_deps = [ 169 "$dir_pw_third_party/embos", 170 dir_pw_function, 171 dir_pw_status, 172 ] 173 public = [ "public/pw_thread_embos/util.h" ] 174 sources = [ "util.cc" ] 175} 176 177pw_source_set("snapshot") { 178 public_configs = [ ":public_include_path" ] 179 public_deps = [ 180 ":config", 181 "$dir_pw_third_party/embos", 182 "$dir_pw_thread:protos.pwpb", 183 "$dir_pw_thread:snapshot", 184 dir_pw_bytes, 185 dir_pw_function, 186 dir_pw_log, 187 dir_pw_protobuf, 188 dir_pw_status, 189 ] 190 public = [ "public/pw_thread_embos/snapshot.h" ] 191 sources = [ "snapshot.cc" ] 192 deps = [ ":util" ] 193} 194 195pw_test_group("tests") { 196 tests = [ ":thread_backend_test" ] 197} 198 199pw_source_set("non_portable_test_thread_options") { 200 public_deps = [ "$dir_pw_thread:non_portable_test_thread_options" ] 201 sources = [ "test_threads.cc" ] 202 deps = [ 203 "$dir_pw_chrono:system_clock", 204 "$dir_pw_thread:sleep", 205 "$dir_pw_thread:thread", 206 dir_pw_assert, 207 dir_pw_log, 208 ] 209} 210 211pw_test("thread_backend_test") { 212 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_embos:thread" 213 deps = [ 214 ":non_portable_test_thread_options", 215 "$dir_pw_thread:thread_facade_test", 216 ] 217} 218 219pw_doc_group("docs") { 220 sources = [ "docs.rst" ] 221} 222