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:id", 104 "$dir_pw_thread:sleep.facade", 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::Thread and the headers needed 115# for 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_span, 129 ] 130 public = [ 131 "public/pw_thread_embos/context.h", 132 "public/pw_thread_embos/options.h", 133 "public/pw_thread_embos/thread_inline.h", 134 "public/pw_thread_embos/thread_native.h", 135 "thread_public_overrides/pw_thread_backend/thread_inline.h", 136 "thread_public_overrides/pw_thread_backend/thread_native.h", 137 ] 138 allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ] 139 sources = [ "thread.cc" ] 140} 141 142config("yield_public_overrides") { 143 include_dirs = [ "yield_public_overrides" ] 144 visibility = [ ":*" ] 145} 146 147# This target provides the backend for pw::thread::yield. 148pw_source_set("yield") { 149 public_configs = [ 150 ":public_include_path", 151 ":yield_public_overrides", 152 ] 153 public = [ 154 "public/pw_thread_embos/yield_inline.h", 155 "yield_public_overrides/pw_thread_backend/yield_inline.h", 156 ] 157 public_deps = [ 158 "$dir_pw_assert", 159 "$dir_pw_third_party/embos", 160 "$dir_pw_thread:id", 161 ] 162 deps = [ "$dir_pw_thread:yield.facade" ] 163} 164 165pw_source_set("util") { 166 public_configs = [ ":public_include_path" ] 167 public_deps = [ 168 "$dir_pw_third_party/embos", 169 dir_pw_function, 170 dir_pw_status, 171 ] 172 public = [ "public/pw_thread_embos/util.h" ] 173 sources = [ "util.cc" ] 174} 175 176pw_source_set("snapshot") { 177 public_configs = [ ":public_include_path" ] 178 public_deps = [ 179 ":config", 180 "$dir_pw_third_party/embos", 181 "$dir_pw_thread:protos.pwpb", 182 "$dir_pw_thread:snapshot", 183 dir_pw_bytes, 184 dir_pw_function, 185 dir_pw_log, 186 dir_pw_protobuf, 187 dir_pw_status, 188 ] 189 public = [ "public/pw_thread_embos/snapshot.h" ] 190 sources = [ "snapshot.cc" ] 191 deps = [ ":util" ] 192} 193 194pw_test_group("tests") { 195 tests = [ ":thread_backend_test" ] 196} 197 198pw_source_set("test_threads") { 199 public_deps = [ "$dir_pw_thread:test_threads" ] 200 sources = [ "test_threads.cc" ] 201 deps = [ 202 "$dir_pw_chrono:system_clock", 203 "$dir_pw_thread:sleep", 204 "$dir_pw_thread:thread", 205 dir_pw_assert, 206 dir_pw_log, 207 ] 208} 209 210pw_test("thread_backend_test") { 211 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_embos:thread" 212 deps = [ 213 ":test_threads", 214 "$dir_pw_thread:thread_facade_test", 215 ] 216} 217 218pw_doc_group("docs") { 219 sources = [ "docs.rst" ] 220} 221