| # Copyright 2020 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| import("//build_overrides/pigweed.gni") |
| |
| import("$dir_pw_build/error.gni") |
| import("$dir_pw_build/target_types.gni") |
| import("$dir_pw_chrono/backend.gni") |
| import("$dir_pw_docgen/docs.gni") |
| import("$dir_pw_thread/backend.gni") |
| import("$dir_pw_unit_test/test.gni") |
| |
| config("public_include_path") { |
| include_dirs = [ "public" ] |
| visibility = [ ":*" ] |
| } |
| |
| config("id_public_overrides") { |
| include_dirs = [ "id_public_overrides" ] |
| visibility = [ ":*" ] |
| } |
| |
| # This target provides the backend for pw::thread::Id & pw::this_thread::get_id. |
| pw_source_set("id") { |
| public_configs = [ |
| ":public_include_path", |
| ":id_public_overrides", |
| ] |
| public = [ |
| "id_public_overrides/pw_thread_backend/id_inline.h", |
| "id_public_overrides/pw_thread_backend/id_native.h", |
| "public/pw_thread_stl/id_inline.h", |
| "public/pw_thread_stl/id_native.h", |
| ] |
| deps = [ "$dir_pw_thread:id.facade" ] |
| } |
| |
| config("thread_public_overrides") { |
| include_dirs = [ "thread_public_overrides" ] |
| visibility = [ ":*" ] |
| } |
| |
| # This target provides the backend for pw::thread::Thread with joining |
| # joining capability. |
| pw_source_set("thread") { |
| public_configs = [ |
| ":public_include_path", |
| ":thread_public_overrides", |
| ] |
| public = [ |
| "public/pw_thread_stl/options.h", |
| "public/pw_thread_stl/thread_inline.h", |
| "public/pw_thread_stl/thread_native.h", |
| "thread_public_overrides/pw_thread_backend/thread_inline.h", |
| "thread_public_overrides/pw_thread_backend/thread_native.h", |
| ] |
| allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ] |
| deps = [ "$dir_pw_thread:thread.facade" ] |
| } |
| |
| pw_build_assert("check_system_clock_backend") { |
| condition = |
| pw_thread_SLEEP_BACKEND != "$dir_pw_thread_stl:sleep" || |
| pw_chrono_SYSTEM_CLOCK_BACKEND == "" || |
| pw_chrono_SYSTEM_CLOCK_BACKEND == "$dir_pw_chrono_stl:system_clock" |
| message = "The STL pw::this_thread::sleep_{for,until} backend only works " + |
| "with the STL pw::chrono::SystemClock backend " + |
| "(pw_chrono_SYSTEM_CLOCK_BACKEND = " + |
| "\"$dir_pw_chrono_stl:system_clock\")" |
| } |
| |
| config("sleep_public_overrides") { |
| include_dirs = [ "sleep_public_overrides" ] |
| visibility = [ ":*" ] |
| } |
| |
| # This target provides the backend for pw::this_thread::sleep_{for,until}. |
| pw_source_set("sleep") { |
| public_configs = [ |
| ":public_include_path", |
| ":sleep_public_overrides", |
| ] |
| public = [ |
| "public/pw_thread_stl/sleep_inline.h", |
| "sleep_public_overrides/pw_thread_backend/sleep_inline.h", |
| ] |
| deps = [ |
| ":check_system_clock_backend", |
| "$dir_pw_chrono:system_clock", |
| "$dir_pw_thread:sleep.facade", |
| ] |
| } |
| |
| config("yield_public_overrides") { |
| include_dirs = [ "yield_public_overrides" ] |
| visibility = [ ":*" ] |
| } |
| |
| # This target provides the backend for pw::this_thread::yield. |
| pw_source_set("yield") { |
| public_configs = [ |
| ":public_include_path", |
| ":yield_public_overrides", |
| ] |
| public = [ |
| "public/pw_thread_stl/yield_inline.h", |
| "yield_public_overrides/pw_thread_backend/yield_inline.h", |
| ] |
| deps = [ "$dir_pw_thread:yield.facade" ] |
| } |
| |
| # This target provides a stub backend for pw::this_thread::thread_iteration. |
| # Iterating over child threads isn't supported by STL, so this only exists |
| # for portability reasons. |
| pw_source_set("thread_iteration") { |
| deps = [ |
| "$dir_pw_thread:thread_iteration.facade", |
| dir_pw_status, |
| ] |
| sources = [ "thread_iteration.cc" ] |
| } |
| |
| pw_test_group("tests") { |
| tests = [ ":thread_backend_test" ] |
| } |
| |
| config("test_thread_context_public_overrides") { |
| include_dirs = [ "test_thread_context_public_overrides" ] |
| visibility = [ ":*" ] |
| } |
| |
| pw_source_set("test_thread_context") { |
| public_deps = [ ":thread" ] |
| public_configs = [ |
| ":public_include_path", |
| ":test_thread_context_public_overrides", |
| ] |
| public = [ |
| "public/pw_thread_stl/test_thread_context_native.h", |
| "test_thread_context_public_overrides/pw_thread_backend/test_thread_context_native.h", |
| ] |
| deps = [ "$dir_pw_thread:test_thread_context.facade" ] |
| } |
| |
| pw_source_set("non_portable_test_thread_options") { |
| public_deps = [ "$dir_pw_thread:non_portable_test_thread_options" ] |
| sources = [ "test_threads.cc" ] |
| deps = [ "$dir_pw_thread:thread" ] |
| } |
| |
| pw_test("thread_backend_test") { |
| enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" && |
| pw_thread_SLEEP_BACKEND != "" |
| deps = [ |
| ":non_portable_test_thread_options", |
| "$dir_pw_thread:thread_facade_test", |
| ] |
| } |
| |
| pw_doc_group("docs") { |
| sources = [ "docs.rst" ] |
| } |