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