1# 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") 20import("$dir_pw_fuzzer/fuzzer.gni") 21import("$dir_pw_thread/backend.gni") 22import("$dir_pw_toolchain/generate_toolchain.gni") 23import("$dir_pw_unit_test/test.gni") 24 25config("public_include_path") { 26 include_dirs = [ "public" ] 27 visibility = [ ":*" ] 28} 29 30pw_source_set("pw_stream") { 31 public_configs = [ ":public_include_path" ] 32 public = [ 33 "public/pw_stream/memory_stream.h", 34 "public/pw_stream/null_stream.h", 35 "public/pw_stream/seek.h", 36 "public/pw_stream/stream.h", 37 ] 38 sources = [ "memory_stream.cc" ] 39 public_deps = [ 40 "$dir_pw_toolchain:sibling_cast", 41 dir_pw_assert, 42 dir_pw_bytes, 43 dir_pw_polyfill, 44 dir_pw_result, 45 dir_pw_span, 46 dir_pw_status, 47 ] 48} 49 50pw_source_set("socket_stream") { 51 public_configs = [ ":public_include_path" ] 52 public_deps = [ 53 ":pw_stream", 54 "$dir_pw_sync:mutex", 55 ] 56 deps = [ 57 dir_pw_assert, 58 dir_pw_log, 59 dir_pw_string, 60 ] 61 sources = [ "socket_stream.cc" ] 62 public = [ "public/pw_stream/socket_stream.h" ] 63 if (current_os == "win") { 64 libs = [ "ws2_32" ] 65 } 66} 67 68pw_source_set("sys_io_stream") { 69 public_configs = [ ":public_include_path" ] 70 public_deps = [ 71 "$dir_pw_stream", 72 "$dir_pw_sys_io", 73 ] 74 public = [ "public/pw_stream/sys_io_stream.h" ] 75} 76 77pw_source_set("std_file_stream") { 78 public_configs = [ ":public_include_path" ] 79 public_deps = [ ":pw_stream" ] 80 deps = [ "$dir_pw_assert" ] 81 public = [ "public/pw_stream/std_file_stream.h" ] 82 sources = [ "std_file_stream.cc" ] 83} 84 85pw_source_set("interval_reader") { 86 public_configs = [ ":public_include_path" ] 87 public_deps = [ 88 ":pw_stream", 89 dir_pw_assert, 90 dir_pw_status, 91 ] 92 public = [ "public/pw_stream/interval_reader.h" ] 93 sources = [ "interval_reader.cc" ] 94} 95 96pw_source_set("mpsc_stream") { 97 public_configs = [ ":public_include_path" ] 98 public_deps = [ 99 ":pw_stream", 100 "$dir_pw_chrono:system_clock", 101 "$dir_pw_containers:intrusive_list", 102 "$dir_pw_sync:lock_annotations", 103 "$dir_pw_sync:mutex", 104 "$dir_pw_sync:timed_thread_notification", 105 dir_pw_assert, 106 dir_pw_bytes, 107 dir_pw_function, 108 dir_pw_status, 109 ] 110 public = [ "public/pw_stream/mpsc_stream.h" ] 111 sources = [ "mpsc_stream.cc" ] 112} 113 114pw_doc_group("docs") { 115 inputs = [ "Kconfig" ] 116 sources = [ 117 "backends.rst", 118 "docs.rst", 119 ] 120 group_deps = [ "py:docs" ] 121} 122 123pw_test_group("tests") { 124 tests = [ 125 ":interval_reader_test", 126 ":memory_stream_test", 127 ":null_stream_test", 128 ":seek_test", 129 ":stream_test", 130 ":mpsc_stream_test", 131 ] 132 133 if (defined(pw_toolchain_SCOPE.is_host_toolchain) && 134 pw_toolchain_SCOPE.is_host_toolchain) { 135 tests += [ ":std_file_stream_test" ] 136 137 # socket_stream_test doesn't compile on Windows. 138 if (host_os != "win") { 139 tests += [ ":socket_stream_test" ] 140 } 141 } 142} 143 144pw_test("memory_stream_test") { 145 sources = [ "memory_stream_test.cc" ] 146 deps = [ ":pw_stream" ] 147} 148 149pw_test("null_stream_test") { 150 sources = [ "null_stream_test.cc" ] 151 deps = [ ":pw_stream" ] 152} 153 154pw_test("std_file_stream_test") { 155 sources = [ "std_file_stream_test.cc" ] 156 deps = [ 157 ":std_file_stream", 158 "$dir_pw_assert", 159 "$dir_pw_bytes", 160 "$dir_pw_containers", 161 "$dir_pw_random", 162 "$dir_pw_result", 163 "$dir_pw_status", 164 "$dir_pw_string", 165 ] 166} 167 168pw_test("seek_test") { 169 sources = [ "seek_test.cc" ] 170 deps = [ ":pw_stream" ] 171} 172 173pw_test("stream_test") { 174 sources = [ "stream_test.cc" ] 175 deps = [ 176 ":pw_stream", 177 "$dir_pw_bytes", 178 "$dir_pw_containers:to_array", 179 "$dir_pw_span", 180 ] 181} 182 183pw_test("interval_reader_test") { 184 sources = [ "interval_reader_test.cc" ] 185 deps = [ ":interval_reader" ] 186} 187 188pw_test("socket_stream_test") { 189 sources = [ "socket_stream_test.cc" ] 190 deps = [ ":socket_stream" ] 191} 192 193pw_test("mpsc_stream_test") { 194 sources = [ "mpsc_stream_test.cc" ] 195 deps = [ 196 ":mpsc_stream", 197 "$dir_pw_containers:vector", 198 "$dir_pw_fuzzer:fuzztest", 199 "$dir_pw_thread:test_thread_context", 200 "$dir_pw_thread:thread", 201 dir_pw_random, 202 ] 203 enable_if = 204 pw_chrono_SYSTEM_CLOCK_BACKEND != "" && pw_thread_THREAD_BACKEND != "" && 205 pw_thread_TEST_THREAD_CONTEXT_BACKEND != "" 206} 207