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_sync:virtual_basic_lockable", 50 dir_pw_assert, 51 dir_pw_bytes, 52 dir_pw_containers, 53 dir_pw_function, 54 dir_pw_result, 55 dir_pw_ring_buffer, 56 dir_pw_status, 57 ] 58 deps = [ 59 dir_pw_assert, 60 dir_pw_log, 61 dir_pw_varint, 62 ] 63 sources = [ "multisink.cc" ] 64} 65 66pw_source_set("util") { 67 public_configs = [ ":public_include_path" ] 68 public = [ "public/pw_multisink/util.h" ] 69 public_deps = [ 70 ":pw_multisink", 71 "$dir_pw_log:protos.pwpb", 72 dir_pw_status, 73 ] 74 deps = [ 75 dir_pw_bytes, 76 dir_pw_function, 77 ] 78 sources = [ "util.cc" ] 79} 80 81pw_source_set("test_thread") { 82 public_configs = [ ":public_include_path" ] 83 public = [ "public/pw_multisink/test_thread.h" ] 84 public_deps = [ "$dir_pw_thread:thread" ] 85} 86 87# Tests that use threads. 88# To instantiate this test based on a thread backend, create a pw_test target 89# that depends on this pw_source_set and a pw_source_set that provides the 90# implementaiton of test_thread. See :stl_multisink_test as an example. 91pw_source_set("multisink_threaded_test") { 92 # TODO: b/303282642 - Remove this testonly 93 testonly = pw_unit_test_TESTONLY 94 95 sources = [ "multisink_threaded_test.cc" ] 96 deps = [ 97 ":pw_multisink", 98 ":test_thread", 99 "$dir_pw_string", 100 "$dir_pw_thread:thread", 101 "$dir_pw_thread:yield", 102 "$dir_pw_unit_test", 103 ] 104} 105 106pw_doc_group("docs") { 107 inputs = [ "Kconfig" ] 108 sources = [ "docs.rst" ] 109} 110 111pw_test("multisink_test") { 112 sources = [ "multisink_test.cc" ] 113 deps = [ 114 ":pw_multisink", 115 dir_pw_function, 116 dir_pw_status, 117 ] 118} 119 120pw_source_set("stl_test_thread") { 121 sources = [ "stl_test_thread.cc" ] 122 deps = [ 123 ":test_thread", 124 "$dir_pw_thread:thread", 125 "$dir_pw_thread_stl:thread", 126 ] 127} 128 129pw_test("stl_multisink_threaded_test") { 130 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" 131 deps = [ 132 ":multisink_threaded_test", 133 ":stl_test_thread", 134 ] 135} 136 137pw_test_group("tests") { 138 tests = [ 139 ":multisink_test", 140 ":stl_multisink_threaded_test", 141 ] 142} 143