blob: 637d2c6388dffc42b735fc1001c916bb74262964 [file] [log] [blame]
Ewout van Bekkume3b56032020-12-22 12:00:18 -08001# 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")
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -080020import("$dir_pw_thread/backend.gni")
21import("$dir_pw_unit_test/test.gni")
Ewout van Bekkume3b56032020-12-22 12:00:18 -080022
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
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -080048# 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
Ewout van Bekkume3b56032020-12-22 12:00:18 -080066# 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
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800102pw_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") {
Anthony DiGirolamocce560d2021-04-29 19:02:51 -0700113 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" &&
114 pw_thread_SLEEP_BACKEND != ""
Ewout van Bekkum0f3901e2020-12-22 12:00:18 -0800115 deps = [
116 ":test_threads",
117 "$dir_pw_thread:thread_facade_test",
118 ]
119}
120
Ewout van Bekkume3b56032020-12-22 12:00:18 -0800121pw_doc_group("docs") {
122 sources = [ "docs.rst" ]
123}