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 15load("@rules_cc//cc:cc_library.bzl", "cc_library") 16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") 17load("//pw_build:compatibility.bzl", "boolean_constraint_value", "incompatible_with_mcu") 18load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 19 20package( 21 default_visibility = ["//visibility:public"], 22) 23 24licenses(["notice"]) 25 26cc_library( 27 name = "pw_stream", 28 srcs = [ 29 "memory_stream.cc", 30 ], 31 hdrs = [ 32 "public/pw_stream/memory_stream.h", 33 "public/pw_stream/null_stream.h", 34 "public/pw_stream/seek.h", 35 "public/pw_stream/stream.h", 36 ], 37 strip_include_prefix = "public", 38 deps = [ 39 "//pw_assert:assert", 40 "//pw_bytes", 41 "//pw_polyfill", 42 "//pw_result", 43 "//pw_span", 44 "//pw_status", 45 "//pw_toolchain:sibling_cast", 46 ], 47) 48 49boolean_constraint_value(name = "socket_stream_compatible") 50 51cc_library( 52 name = "socket_stream", 53 srcs = ["socket_stream.cc"], 54 hdrs = ["public/pw_stream/socket_stream.h"], 55 implementation_deps = ["//pw_assert:check"], 56 strip_include_prefix = "public", 57 target_compatible_with = incompatible_with_mcu(unless_platform_has = ":socket_stream_compatible"), 58 deps = [ 59 ":pw_stream", 60 "//pw_log", 61 "//pw_result", 62 "//pw_span", 63 "//pw_status", 64 "//pw_string:to_string", 65 "//pw_sync:lock_annotations", 66 "//pw_sync:mutex", 67 "//pw_sys_io", 68 ], 69) 70 71cc_library( 72 name = "sys_io_stream", 73 hdrs = ["public/pw_stream/sys_io_stream.h"], 74 strip_include_prefix = "public", 75 deps = [ 76 "//pw_stream", 77 "//pw_sys_io", 78 ], 79) 80 81cc_library( 82 name = "std_file_stream", 83 srcs = ["std_file_stream.cc"], 84 hdrs = ["public/pw_stream/std_file_stream.h"], 85 implementation_deps = ["//pw_assert:check"], 86 strip_include_prefix = "public", 87 target_compatible_with = incompatible_with_mcu(), 88 deps = [":pw_stream"], 89) 90 91cc_library( 92 name = "interval_reader", 93 srcs = ["interval_reader.cc"], 94 hdrs = ["public/pw_stream/interval_reader.h"], 95 implementation_deps = ["//pw_assert:check"], 96 strip_include_prefix = "public", 97 deps = [ 98 ":pw_stream", 99 "//pw_assert:assert", 100 "//pw_status", 101 ], 102) 103 104cc_library( 105 name = "mpsc_stream", 106 srcs = ["mpsc_stream.cc"], 107 hdrs = ["public/pw_stream/mpsc_stream.h"], 108 implementation_deps = ["//pw_assert:check"], 109 strip_include_prefix = "public", 110 deps = [ 111 ":pw_stream", 112 "//pw_bytes", 113 "//pw_chrono:system_clock.facade", 114 "//pw_containers:intrusive_list", 115 "//pw_function", 116 "//pw_status", 117 "//pw_sync:lock_annotations", 118 "//pw_sync:mutex", 119 "//pw_sync:timed_thread_notification", 120 ], 121) 122 123pw_cc_test( 124 name = "memory_stream_test", 125 srcs = ["memory_stream_test.cc"], 126 deps = [ 127 ":pw_stream", 128 "//pw_preprocessor", 129 "//pw_status", 130 ], 131) 132 133pw_cc_test( 134 name = "null_stream_test", 135 srcs = ["null_stream_test.cc"], 136 deps = [":pw_stream"], 137) 138 139pw_cc_test( 140 name = "std_file_stream_test", 141 srcs = ["std_file_stream_test.cc"], 142 target_compatible_with = incompatible_with_mcu(), 143 deps = [ 144 ":std_file_stream", 145 "//pw_assert:assert", 146 "//pw_bytes", 147 "//pw_containers:algorithm", 148 "//pw_random", 149 "//pw_result", 150 "//pw_span", 151 "//pw_status", 152 "//pw_string:builder", 153 ], 154) 155 156pw_cc_test( 157 name = "seek_test", 158 srcs = ["seek_test.cc"], 159 deps = [":pw_stream"], 160) 161 162pw_cc_test( 163 name = "stream_test", 164 srcs = ["stream_test.cc"], 165 deps = [ 166 ":pw_stream", 167 "//pw_assert:check", 168 "//pw_bytes", 169 "//pw_containers:to_array", 170 "//pw_span", 171 ], 172) 173 174pw_cc_test( 175 name = "interval_reader_test", 176 srcs = ["interval_reader_test.cc"], 177 deps = [ 178 ":interval_reader", 179 ":pw_stream", 180 "//pw_result", 181 ], 182) 183 184pw_cc_test( 185 name = "socket_stream_test", 186 srcs = ["socket_stream_test.cc"], 187 deps = [ 188 ":socket_stream", 189 "//pw_result", 190 "//pw_status", 191 ], 192) 193 194pw_cc_test( 195 name = "mpsc_stream_test", 196 srcs = ["mpsc_stream_test.cc"], 197 # TODO: b/361369435 - This test crashes on rp2. 198 target_compatible_with = select({ 199 "@pico-sdk//bazel/constraint:rp2040": ["@platforms//:incompatible"], 200 "@pico-sdk//bazel/constraint:rp2350": ["@platforms//:incompatible"], 201 "//conditions:default": [], 202 }), 203 deps = [ 204 ":mpsc_stream", 205 "//pw_containers:vector", 206 "//pw_fuzzer:fuzztest", 207 "//pw_random", 208 "//pw_thread:test_thread_context", 209 "//pw_thread:thread", 210 ], 211) 212 213filegroup( 214 name = "doxygen", 215 srcs = [ 216 "public/pw_stream/stream.h", 217 ], 218) 219 220sphinx_docs_library( 221 name = "docs", 222 srcs = [ 223 "Kconfig", 224 "backends.rst", 225 "docs.rst", 226 "//pw_stream/py:docs", 227 ], 228 prefix = "pw_stream/", 229 target_compatible_with = incompatible_with_mcu(), 230) 231