• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/module_config.gni")
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_thread/backend.gni")
21import("$dir_pw_unit_test/test.gni")
22
23declare_args() {
24  # The build target that overrides the default configuration options for this
25  # module. This should point to a source set that provides defines through a
26  # public config (which may -include a file or add defines directly).
27  pw_multisink_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
28}
29
30config("public_include_path") {
31  include_dirs = [ "public" ]
32  visibility = [ ":*" ]
33}
34
35pw_source_set("config") {
36  public = [ "public/pw_multisink/config.h" ]
37  public_configs = [ ":public_include_path" ]
38  public_deps = [ pw_multisink_CONFIG ]
39}
40
41pw_source_set("pw_multisink") {
42  public_configs = [ ":public_include_path" ]
43  public = [ "public/pw_multisink/multisink.h" ]
44  public_deps = [
45    ":config",
46    "$dir_pw_sync:interrupt_spin_lock",
47    "$dir_pw_sync:lock_annotations",
48    "$dir_pw_sync:mutex",
49    dir_pw_bytes,
50    dir_pw_containers,
51    dir_pw_function,
52    dir_pw_result,
53    dir_pw_ring_buffer,
54    dir_pw_status,
55  ]
56  deps = [
57    dir_pw_assert,
58    dir_pw_log,
59    dir_pw_varint,
60  ]
61  sources = [ "multisink.cc" ]
62}
63
64pw_source_set("util") {
65  public_configs = [ ":public_include_path" ]
66  public = [ "public/pw_multisink/util.h" ]
67  public_deps = [
68    ":pw_multisink",
69    "$dir_pw_log:protos.pwpb",
70    dir_pw_status,
71  ]
72  deps = [
73    dir_pw_bytes,
74    dir_pw_function,
75  ]
76  sources = [ "util.cc" ]
77}
78
79pw_source_set("test_thread") {
80  public_configs = [ ":public_include_path" ]
81  public = [ "public/pw_multisink/test_thread.h" ]
82  public_deps = [ "$dir_pw_thread:thread" ]
83}
84
85# Tests that use threads.
86# To instantiate this test based on a thread backend, create a pw_test target
87# that depends on this pw_source_set and a pw_source_set that provides the
88# implementaiton of test_thread. See :stl_multisink_test as an example.
89pw_source_set("multisink_threaded_test") {
90  sources = [ "multisink_threaded_test.cc" ]
91  deps = [
92    ":pw_multisink",
93    ":test_thread",
94    "$dir_pw_string",
95    "$dir_pw_thread:thread",
96    "$dir_pw_thread:yield",
97    "$dir_pw_unit_test",
98  ]
99}
100
101pw_doc_group("docs") {
102  sources = [ "docs.rst" ]
103}
104
105pw_test("multisink_test") {
106  sources = [ "multisink_test.cc" ]
107  deps = [
108    ":pw_multisink",
109    dir_pw_function,
110    dir_pw_status,
111  ]
112}
113
114pw_source_set("stl_test_thread") {
115  sources = [ "stl_test_thread.cc" ]
116  deps = [
117    ":test_thread",
118    "$dir_pw_thread:thread",
119    "$dir_pw_thread_stl:thread",
120  ]
121}
122
123pw_test("stl_multisink_threaded_test") {
124  enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread"
125  deps = [
126    ":multisink_threaded_test",
127    ":stl_test_thread",
128  ]
129}
130
131pw_test_group("tests") {
132  tests = [
133    ":multisink_test",
134    ":stl_multisink_threaded_test",
135  ]
136}
137