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