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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_async2/backend.gni") 18import("$dir_pw_build/target_types.gni") 19import("$dir_pw_docgen/docs.gni") 20import("$dir_pw_unit_test/test.gni") 21 22config("public_include_path") { 23 include_dirs = [ "public" ] 24 visibility = [ ":*" ] 25} 26 27pw_source_set("chunk") { 28 public_configs = [ ":public_include_path" ] 29 public = [ "public/pw_multibuf/chunk.h" ] 30 sources = [ "chunk.cc" ] 31 public_deps = [ 32 "$dir_pw_sync:mutex", 33 dir_pw_assert, 34 dir_pw_bytes, 35 dir_pw_preprocessor, 36 dir_pw_span, 37 ] 38 deps = [ "$dir_pw_assert:check" ] 39} 40 41pw_source_set("header_chunk_region_tracker") { 42 public_configs = [ ":public_include_path" ] 43 public = [ "public/pw_multibuf/header_chunk_region_tracker.h" ] 44 public_deps = [ 45 ":chunk", 46 dir_pw_allocator, 47 dir_pw_bytes, 48 ] 49} 50 51pw_test("header_chunk_region_tracker_test") { 52 deps = [ 53 ":chunk", 54 ":header_chunk_region_tracker", 55 "$dir_pw_allocator:testing", 56 dir_pw_status, 57 ] 58 sources = [ "header_chunk_region_tracker_test.cc" ] 59} 60 61pw_source_set("single_chunk_region_tracker") { 62 public_configs = [ ":public_include_path" ] 63 public = [ "public/pw_multibuf/single_chunk_region_tracker.h" ] 64 public_deps = [ 65 ":chunk", 66 dir_pw_assert, 67 dir_pw_bytes, 68 ] 69} 70 71pw_test("single_chunk_region_tracker_test") { 72 deps = [ 73 ":chunk", 74 ":single_chunk_region_tracker", 75 ] 76 sources = [ "single_chunk_region_tracker_test.cc" ] 77 78 # TODO: b/260624583 - Fix this for //targets/rp2040 79 enable_if = pw_build_EXECUTABLE_TARGET_TYPE != "pico_executable" 80} 81 82pw_test("chunk_test") { 83 deps = [ 84 ":chunk", 85 ":header_chunk_region_tracker", 86 "$dir_pw_allocator:testing", 87 ] 88 sources = [ "chunk_test.cc" ] 89} 90 91pw_source_set("pw_multibuf") { 92 public_configs = [ ":public_include_path" ] 93 public = [ "public/pw_multibuf/multibuf.h" ] 94 sources = [ "multibuf.cc" ] 95 public_deps = [ 96 ":chunk", 97 dir_pw_preprocessor, 98 dir_pw_status, 99 ] 100} 101 102pw_test("multibuf_test") { 103 deps = [ 104 ":internal_test_utils", 105 ":pw_multibuf", 106 dir_pw_bytes, 107 ] 108 sources = [ "multibuf_test.cc" ] 109} 110 111pw_source_set("allocator") { 112 public_configs = [ ":public_include_path" ] 113 public = [ "public/pw_multibuf/allocator.h" ] 114 sources = [ "allocator.cc" ] 115 public_deps = [ 116 ":pw_multibuf", 117 "$dir_pw_containers:intrusive_forward_list", 118 "$dir_pw_result", 119 "$dir_pw_sync:interrupt_spin_lock", 120 ] 121} 122 123pw_source_set("allocator_async") { 124 public_configs = [ ":public_include_path" ] 125 public = [ "public/pw_multibuf/allocator_async.h" ] 126 sources = [ "allocator_async.cc" ] 127 public_deps = [ 128 ":allocator", 129 "$dir_pw_async2:dispatcher", 130 "$dir_pw_async2:poll", 131 ] 132} 133 134# TODO: https://pwbug.dev/384583239 - Split async into its own test. 135pw_test("allocator_test") { 136 enable_if = pw_async2_DISPATCHER_BACKEND != "" 137 deps = [ 138 ":allocator", 139 ":allocator_async", 140 "$dir_pw_async2:dispatcher", 141 "$dir_pw_async2:poll", 142 ] 143 sources = [ "allocator_test.cc" ] 144} 145 146pw_source_set("simple_allocator") { 147 public_configs = [ ":public_include_path" ] 148 public = [ "public/pw_multibuf/simple_allocator.h" ] 149 sources = [ "simple_allocator.cc" ] 150 public_deps = [ 151 ":allocator", 152 ":pw_multibuf", 153 "$dir_pw_allocator:allocator", 154 "$dir_pw_containers:intrusive_list", 155 ] 156 deps = [ "$dir_pw_bytes:alignment" ] 157} 158 159pw_test("simple_allocator_test") { 160 enable_if = pw_async2_DISPATCHER_BACKEND != "" 161 deps = [ 162 ":simple_allocator", 163 "$dir_pw_allocator:null_allocator", 164 "$dir_pw_allocator:testing", 165 ] 166 sources = [ "simple_allocator_test.cc" ] 167} 168 169pw_source_set("stream") { 170 public_configs = [ ":public_include_path" ] 171 public = [ "public/pw_multibuf/stream.h" ] 172 public_deps = [ 173 ":pw_multibuf", 174 dir_pw_status, 175 dir_pw_stream, 176 ] 177 sources = [ "stream.cc" ] 178} 179 180pw_test("stream_test") { 181 enable_if = pw_async2_DISPATCHER_BACKEND != "" 182 deps = [ 183 ":internal_test_utils", 184 ":stream", 185 ] 186 sources = [ "stream_test.cc" ] 187} 188 189pw_source_set("from_span") { 190 public_configs = [ ":public_include_path" ] 191 public = [ "public/pw_multibuf/from_span.h" ] 192 public_deps = [ 193 ":pw_multibuf", 194 dir_pw_allocator, 195 dir_pw_function, 196 ] 197 sources = [ "from_span.cc" ] 198} 199 200pw_test("from_span_test") { 201 deps = [ 202 ":from_span", 203 "$dir_pw_allocator:testing", 204 ] 205 sources = [ "from_span_test.cc" ] 206} 207 208pw_source_set("testing") { 209 public_configs = [ ":public_include_path" ] 210 public = [ "public/pw_multibuf/simple_allocator_for_test.h" ] 211 public_deps = [ 212 ":simple_allocator", 213 "$dir_pw_allocator:synchronized_allocator", 214 "$dir_pw_allocator:testing", 215 "$dir_pw_sync:mutex", 216 dir_pw_assert, 217 ] 218} 219 220pw_source_set("internal_test_utils") { 221 sources = [ "pw_multibuf_private/test_utils.h" ] 222 public_deps = [ 223 ":header_chunk_region_tracker", 224 ":pw_multibuf", 225 "$dir_pw_allocator:testing", 226 dir_pw_assert, 227 dir_pw_bytes, 228 ] 229 visibility = [ ":*" ] 230} 231 232pw_test_group("tests") { 233 tests = [ 234 ":allocator_test", 235 ":chunk_test", 236 ":from_span_test", 237 ":header_chunk_region_tracker_test", 238 ":multibuf_test", 239 ":simple_allocator_test", 240 ":single_chunk_region_tracker_test", 241 ":stream_test", 242 ] 243} 244 245pw_doc_group("docs") { 246 sources = [ "docs.rst" ] 247} 248