1# Copyright 2023 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_pigweed/build_overrides/pi_pico.gni") 18import("$dir_pw_async2/backend.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_docgen/docs.gni") 21import("$dir_pw_thread/backend.gni") 22import("$dir_pw_unit_test/test.gni") 23 24config("public_include_path") { 25 include_dirs = [ "public" ] 26 visibility = [ ":*" ] 27} 28 29pw_source_set("pw_channel") { 30 public_configs = [ ":public_include_path" ] 31 public = [ 32 "public/pw_channel/channel.h", 33 "public/pw_channel/properties.h", 34 ] 35 public_deps = [ 36 "$dir_pw_async2:dispatcher", 37 "$dir_pw_async2:poll", 38 "$dir_pw_multibuf:allocator", 39 "$dir_pw_multibuf:allocator_async", 40 "$dir_pw_toolchain:sibling_cast", 41 dir_pw_assert, 42 dir_pw_bytes, 43 dir_pw_multibuf, 44 dir_pw_result, 45 dir_pw_span, 46 dir_pw_status, 47 ] 48 sources = [ "public/pw_channel/internal/channel_specializations.h" ] 49} 50 51pw_source_set("forwarding_channel") { 52 public_configs = [ ":public_include_path" ] 53 public = [ "public/pw_channel/forwarding_channel.h" ] 54 sources = [ "forwarding_channel.cc" ] 55 public_deps = [ 56 ":pw_channel", 57 "$dir_pw_multibuf:allocator", 58 "$dir_pw_multibuf:allocator_async", 59 "$dir_pw_sync:mutex", 60 ] 61} 62 63pw_test("forwarding_channel_test") { 64 sources = [ "forwarding_channel_test.cc" ] 65 deps = [ 66 ":forwarding_channel", 67 "$dir_pw_allocator:testing", 68 "$dir_pw_multibuf:header_chunk_region_tracker", 69 "$dir_pw_multibuf:simple_allocator", 70 dir_pw_preprocessor, 71 ] 72 enable_if = pw_async2_DISPATCHER_BACKEND != "" 73} 74 75pw_source_set("loopback_channel") { 76 public_configs = [ ":public_include_path" ] 77 public = [ "public/pw_channel/loopback_channel.h" ] 78 sources = [ "loopback_channel.cc" ] 79 public_deps = [ 80 ":pw_channel", 81 "$dir_pw_multibuf:allocator", 82 "$dir_pw_multibuf:allocator_async", 83 ] 84} 85 86pw_test("loopback_channel_test") { 87 sources = [ "loopback_channel_test.cc" ] 88 deps = [ 89 ":loopback_channel", 90 "$dir_pw_multibuf:allocator_async", 91 "$dir_pw_multibuf:testing", 92 ] 93 enable_if = pw_async2_DISPATCHER_BACKEND != "" 94} 95 96pw_source_set("epoll_channel") { 97 public_configs = [ ":public_include_path" ] 98 public = [ "public/pw_channel/epoll_channel.h" ] 99 sources = [ "epoll_channel.cc" ] 100 public_deps = [ 101 ":pw_channel", 102 "$dir_pw_multibuf:allocator", 103 "$dir_pw_multibuf:allocator_async", 104 "$dir_pw_sync:mutex", 105 ] 106 deps = [ dir_pw_log ] 107} 108 109pw_test("epoll_channel_test") { 110 sources = [ "epoll_channel_test.cc" ] 111 deps = [ 112 ":epoll_channel", 113 "$dir_pw_multibuf:allocator", 114 "$dir_pw_multibuf:allocator_async", 115 "$dir_pw_multibuf:testing", 116 "$dir_pw_thread:sleep", 117 "$dir_pw_thread:thread", 118 "$dir_pw_thread_stl:thread", 119 ] 120 enable_if = 121 pw_async2_DISPATCHER_BACKEND == "$dir_pw_async2_epoll:dispatcher_backend" 122} 123 124if (pw_build_EXECUTABLE_TARGET_TYPE == "pico_executable") { 125 pw_source_set("rp2_stdio_channel") { 126 public_configs = [ ":public_include_path" ] 127 public = [ "public/pw_channel/rp2_stdio_channel.h" ] 128 sources = [ "rp2_stdio_channel.cc" ] 129 public_deps = [ 130 ":pw_channel", 131 "$dir_pw_multibuf:allocator", 132 "$dir_pw_multibuf:allocator_async", 133 ] 134 deps = [ 135 "$PICO_ROOT/src/common/pico_base", 136 "$PICO_ROOT/src/common/pico_stdlib", 137 dir_pw_log, 138 ] 139 } 140} 141 142pw_source_set("stream_channel") { 143 public_configs = [ ":public_include_path" ] 144 public = [ "public/pw_channel/stream_channel.h" ] 145 sources = [ "stream_channel.cc" ] 146 public_deps = [ 147 ":pw_channel", 148 "$dir_pw_sync:interrupt_spin_lock", 149 "$dir_pw_sync:thread_notification", 150 "$dir_pw_thread:thread", 151 dir_pw_stream, 152 ] 153 deps = [ dir_pw_log ] 154} 155 156pw_test("stream_channel_test") { 157 sources = [ "stream_channel_test.cc" ] 158 deps = [ 159 ":stream_channel", 160 "$dir_pw_async2:pend_func_task", 161 "$dir_pw_multibuf:allocator_async", 162 "$dir_pw_multibuf:testing", 163 "$dir_pw_stream:mpsc_stream", 164 "$dir_pw_thread:test_thread_context", 165 "$dir_pw_thread:thread", 166 "$dir_pw_toolchain:globals", 167 "$dir_pw_toolchain:no_destructor", 168 "$dir_pw_unit_test", 169 dir_pw_stream, 170 ] 171 enable_if = host_os != "win" && pw_async2_DISPATCHER_BACKEND != "" && 172 pw_thread_THREAD_BACKEND != "" 173} 174 175pw_doc_group("docs") { 176 sources = [ 177 "design.rst", 178 "docs.rst", 179 "guides.rst", 180 "reference.rst", 181 ] 182} 183 184pw_test_group("tests") { 185 tests = [ 186 ":channel_test", 187 ":epoll_channel_test", 188 ":forwarding_channel_test", 189 ":loopback_channel_test", 190 ":stream_channel_test", 191 ] 192} 193 194pw_test("channel_test") { 195 sources = [ "channel_test.cc" ] 196 deps = [ 197 ":pw_channel", 198 "$dir_pw_allocator:testing", 199 "$dir_pw_multibuf:allocator_async", 200 "$dir_pw_multibuf:simple_allocator", 201 ] 202 enable_if = pw_async2_DISPATCHER_BACKEND != "" 203 negative_compilation_tests = true 204} 205