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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/error.gni") 18import("$dir_pw_build/target_types.gni") 19import("$dir_pw_chrono/backend.gni") 20import("$dir_pw_docgen/docs.gni") 21import("$dir_pw_thread/backend.gni") 22import("$dir_pw_unit_test/test.gni") 23 24config("public_include_path") { 25 include_dirs = [ "public" ] 26 visibility = [ ":*" ] 27} 28 29config("backend_config") { 30 include_dirs = [ "public_overrides" ] 31 visibility = [ ":*" ] 32} 33 34# This target provides the backend for pw::thread::Id & pw::this_thread::get_id. 35pw_source_set("id") { 36 public_configs = [ 37 ":public_include_path", 38 ":backend_config", 39 ] 40 public = [ 41 "public/pw_thread_stl/id_inline.h", 42 "public/pw_thread_stl/id_native.h", 43 "public_overrides/pw_thread_backend/id_inline.h", 44 "public_overrides/pw_thread_backend/id_native.h", 45 ] 46 deps = [ "$dir_pw_thread:id.facade" ] 47} 48 49# This target provides the backend for pw::thread::Thread with joining 50# joining capability. 51pw_source_set("thread") { 52 public_configs = [ 53 ":public_include_path", 54 ":backend_config", 55 ] 56 public = [ 57 "public/pw_thread_stl/options.h", 58 "public/pw_thread_stl/thread_inline.h", 59 "public/pw_thread_stl/thread_native.h", 60 "public_overrides/pw_thread_backend/thread_inline.h", 61 "public_overrides/pw_thread_backend/thread_native.h", 62 ] 63 allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ] 64 deps = [ "$dir_pw_thread:thread.facade" ] 65} 66 67pw_build_assert("check_system_clock_backend") { 68 condition = 69 pw_thread_SLEEP_BACKEND != "$dir_pw_thread_stl:sleep" || 70 pw_chrono_SYSTEM_CLOCK_BACKEND == "" || 71 pw_chrono_SYSTEM_CLOCK_BACKEND == "$dir_pw_chrono_stl:system_clock" 72 message = "The STL pw::this_thread::sleep_{for,until} backend only works " + 73 "with the STL pw::chrono::SystemClock backend " + 74 "(pw_chrono_SYSTEM_CLOCK_BACKEND = " + 75 "\"$dir_pw_chrono_stl:system_clock\")" 76} 77 78# This target provides the backend for pw::this_thread::sleep_{for,until}. 79pw_source_set("sleep") { 80 public_configs = [ 81 ":public_include_path", 82 ":backend_config", 83 ] 84 public = [ 85 "public/pw_thread_stl/sleep_inline.h", 86 "public_overrides/pw_thread_backend/sleep_inline.h", 87 ] 88 deps = [ 89 ":check_system_clock_backend", 90 "$dir_pw_chrono:system_clock", 91 "$dir_pw_thread:sleep.facade", 92 ] 93} 94 95# This target provides the backend for pw::this_thread::yield. 96pw_source_set("yield") { 97 public_configs = [ 98 ":public_include_path", 99 ":backend_config", 100 ] 101 public = [ 102 "public/pw_thread_stl/yield_inline.h", 103 "public_overrides/pw_thread_backend/yield_inline.h", 104 ] 105 deps = [ "$dir_pw_thread:yield.facade" ] 106} 107 108pw_test_group("tests") { 109 tests = [ ":thread_backend_test" ] 110} 111 112pw_source_set("test_threads") { 113 public_deps = [ "$dir_pw_thread:test_threads" ] 114 sources = [ "test_threads.cc" ] 115 deps = [ "$dir_pw_thread:thread" ] 116} 117 118pw_test("thread_backend_test") { 119 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" && 120 pw_thread_SLEEP_BACKEND != "" 121 deps = [ 122 ":test_threads", 123 "$dir_pw_thread:thread_facade_test", 124 ] 125} 126 127pw_doc_group("docs") { 128 sources = [ "docs.rst" ] 129} 130