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