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