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 15load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 16 17package(default_visibility = ["//visibility:public"]) 18 19licenses(["notice"]) 20 21cc_library( 22 name = "chunk", 23 srcs = ["chunk.cc"], 24 hdrs = ["public/pw_multibuf/chunk.h"], 25 strip_include_prefix = "public", 26 deps = [ 27 "//pw_assert", 28 "//pw_bytes", 29 "//pw_preprocessor", 30 "//pw_span", 31 "//pw_sync:interrupt_spin_lock", 32 ], 33) 34 35cc_library( 36 name = "header_chunk_region_tracker", 37 hdrs = ["public/pw_multibuf/header_chunk_region_tracker.h"], 38 strip_include_prefix = "public", 39 deps = [ 40 ":chunk", 41 "//pw_allocator:allocator", 42 "//pw_bytes", 43 ], 44) 45 46cc_library( 47 name = "single_chunk_region_tracker", 48 hdrs = ["public/pw_multibuf/single_chunk_region_tracker.h"], 49 strip_include_prefix = "public", 50 deps = [ 51 ":chunk", 52 "//pw_assert", 53 "//pw_bytes", 54 ], 55) 56 57pw_cc_test( 58 name = "chunk_test", 59 srcs = ["chunk_test.cc"], 60 deps = [ 61 ":chunk", 62 ":header_chunk_region_tracker", 63 "//pw_allocator:testing", 64 "//pw_unit_test", 65 ], 66) 67 68pw_cc_test( 69 name = "header_chunk_region_tracker_test", 70 srcs = ["header_chunk_region_tracker_test.cc"], 71 deps = [ 72 ":chunk", 73 ":header_chunk_region_tracker", 74 "//pw_allocator:testing", 75 "//pw_status", 76 ], 77) 78 79pw_cc_test( 80 name = "single_chunk_region_tracker_test", 81 srcs = ["single_chunk_region_tracker_test.cc"], 82 # TODO: b/260624583 - Fix this for rp2040 83 target_compatible_with = select({ 84 "//pw_build/constraints/chipset:rp2040": ["@platforms//:incompatible"], 85 "//conditions:default": [], 86 }), 87 deps = [ 88 ":chunk", 89 ":single_chunk_region_tracker", 90 ], 91) 92 93cc_library( 94 name = "pw_multibuf", 95 srcs = ["multibuf.cc"], 96 hdrs = ["public/pw_multibuf/multibuf.h"], 97 strip_include_prefix = "public", 98 deps = [ 99 ":chunk", 100 "//pw_preprocessor", 101 "//pw_status", 102 ], 103) 104 105pw_cc_test( 106 name = "multibuf_test", 107 srcs = ["multibuf_test.cc"], 108 deps = [ 109 ":internal_test_utils", 110 ":pw_multibuf", 111 "//pw_bytes", 112 "//pw_unit_test", 113 ], 114) 115 116cc_library( 117 name = "allocator", 118 srcs = ["allocator.cc"], 119 hdrs = ["public/pw_multibuf/allocator.h"], 120 strip_include_prefix = "public", 121 deps = [ 122 ":pw_multibuf", 123 "//pw_async2:dispatcher", 124 "//pw_async2:poll", 125 "//pw_containers:intrusive_forward_list", 126 "//pw_result", 127 ], 128) 129 130pw_cc_test( 131 name = "allocator_test", 132 srcs = ["allocator_test.cc"], 133 deps = [ 134 ":allocator", 135 "//pw_async2:dispatcher", 136 "//pw_async2:poll", 137 "//pw_unit_test", 138 ], 139) 140 141cc_library( 142 name = "simple_allocator", 143 srcs = ["simple_allocator.cc"], 144 hdrs = ["public/pw_multibuf/simple_allocator.h"], 145 strip_include_prefix = "public", 146 deps = [ 147 ":allocator", 148 ":pw_multibuf", 149 "//pw_allocator:allocator", 150 "//pw_containers:intrusive_list", 151 ], 152) 153 154pw_cc_test( 155 name = "simple_allocator_test", 156 srcs = ["simple_allocator_test.cc"], 157 deps = [ 158 ":simple_allocator", 159 "//pw_allocator:null_allocator", 160 "//pw_allocator:testing", 161 "//pw_async2:dispatcher", 162 "//pw_async2:poll", 163 "//pw_unit_test", 164 ], 165) 166 167cc_library( 168 name = "stream", 169 srcs = ["stream.cc"], 170 hdrs = ["public/pw_multibuf/stream.h"], 171 strip_include_prefix = "public", 172 deps = [ 173 ":pw_multibuf", 174 "//pw_status", 175 "//pw_stream", 176 ], 177) 178 179pw_cc_test( 180 name = "stream_test", 181 srcs = ["stream_test.cc"], 182 deps = [ 183 ":internal_test_utils", 184 ":pw_multibuf", 185 ":stream", 186 "//pw_unit_test", 187 ], 188) 189 190cc_library( 191 name = "from_span", 192 srcs = ["from_span.cc"], 193 hdrs = ["public/pw_multibuf/from_span.h"], 194 strip_include_prefix = "public", 195 deps = [ 196 ":pw_multibuf", 197 "//pw_allocator:allocator", 198 "//pw_function", 199 ], 200) 201 202pw_cc_test( 203 name = "from_span_test", 204 srcs = ["from_span_test.cc"], 205 deps = [ 206 ":from_span", 207 "//pw_allocator:testing", 208 "//pw_unit_test", 209 ], 210) 211 212cc_library( 213 name = "testing", 214 testonly = True, 215 hdrs = ["public/pw_multibuf/simple_allocator_for_test.h"], 216 strip_include_prefix = "public", 217 deps = [ 218 ":simple_allocator", 219 "//pw_allocator:testing", 220 "//pw_assert", 221 ], 222) 223 224cc_library( 225 name = "internal_test_utils", 226 testonly = True, 227 hdrs = ["pw_multibuf_private/test_utils.h"], 228 includes = ["pw_multibuf_private"], 229 visibility = ["//visibility:private"], 230 deps = [ 231 ":header_chunk_region_tracker", 232 ":pw_multibuf", 233 "//pw_allocator:testing", 234 "//pw_assert", 235 "//pw_bytes", 236 "//pw_status", 237 ], 238) 239 240filegroup( 241 name = "doxygen", 242 srcs = [ 243 "public/pw_multibuf/allocator.h", 244 "public/pw_multibuf/chunk.h", 245 "public/pw_multibuf/from_span.h", 246 "public/pw_multibuf/header_chunk_region_tracker.h", 247 "public/pw_multibuf/multibuf.h", 248 "public/pw_multibuf/simple_allocator.h", 249 "public/pw_multibuf/simple_allocator_for_test.h", 250 "public/pw_multibuf/single_chunk_region_tracker.h", 251 "public/pw_multibuf/stream.h", 252 ], 253) 254