1# Copyright 2019 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_bloat/bloat.gni") 18import("$dir_pw_build/module_config.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_docgen/docs.gni") 21import("$dir_pw_toolchain/traits.gni") 22import("$dir_pw_unit_test/test.gni") 23 24# Module configuration 25 26declare_args() { 27 # The build target that overrides the default configuration options for this 28 # module. This should point to a source set that provides defines through a 29 # public config (which may -include a file or add defines directly). 30 pw_containers_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 31} 32 33config("public_include_path") { 34 include_dirs = [ "public" ] 35 visibility = [ ":*" ] 36} 37 38pw_source_set("config") { 39 public = [ "public/pw_containers/config.h" ] 40 public_configs = [ ":public_include_path" ] 41 public_deps = [ pw_containers_CONFIG ] 42} 43 44# Libraries 45 46group("pw_containers") { 47 public_deps = [ 48 ":algorithm", 49 ":flat_map", 50 ":inline_deque", 51 ":inline_queue", 52 ":intrusive_list", 53 ":vector", 54 ] 55} 56 57pw_source_set("algorithm") { 58 public_configs = [ ":public_include_path" ] 59 public = [ 60 "public/pw_containers/algorithm.h", 61 "public/pw_containers/internal/algorithm_internal.h", 62 ] 63} 64 65pw_source_set("filtered_view") { 66 public_configs = [ ":public_include_path" ] 67 public = [ "public/pw_containers/filtered_view.h" ] 68 public_deps = [ 69 dir_pw_assert, 70 dir_pw_preprocessor, 71 ] 72} 73 74pw_source_set("flat_map") { 75 public_configs = [ ":public_include_path" ] 76 public = [ "public/pw_containers/flat_map.h" ] 77 public_deps = [ "$dir_pw_assert:assert" ] 78} 79 80pw_source_set("inline_deque") { 81 public_configs = [ ":public_include_path" ] 82 public_deps = [ 83 ":raw_storage", 84 "$dir_pw_toolchain:constexpr_tag", 85 dir_pw_assert, 86 dir_pw_preprocessor, 87 dir_pw_span, 88 ] 89 public = [ "public/pw_containers/inline_deque.h" ] 90} 91 92pw_source_set("inline_queue") { 93 public_configs = [ ":public_include_path" ] 94 public_deps = [ ":inline_deque" ] 95 public = [ "public/pw_containers/inline_queue.h" ] 96} 97 98pw_source_set("iterator") { 99 public_configs = [ ":public_include_path" ] 100 public_deps = [ dir_pw_polyfill ] 101 public = [ "public/pw_containers/iterator.h" ] 102} 103 104pw_source_set("raw_storage") { 105 public_configs = [ ":public_include_path" ] 106 public = [ "public/pw_containers/internal/raw_storage.h" ] 107 visibility = [ ":*" ] 108} 109 110pw_source_set("test_helpers") { 111 public = [ "pw_containers_private/test_helpers.h" ] 112 sources = [ "test_helpers.cc" ] 113 deps = [ dir_pw_assert ] 114 visibility = [ ":*" ] 115} 116 117pw_source_set("to_array") { 118 public_configs = [ ":public_include_path" ] 119 public = [ "public/pw_containers/to_array.h" ] 120} 121 122pw_source_set("inline_var_len_entry_queue") { 123 public_configs = [ ":public_include_path" ] 124 public_deps = [ 125 "$dir_pw_toolchain:constexpr_tag", 126 dir_pw_varint, 127 ] 128 deps = [ dir_pw_assert ] 129 public = [ "public/pw_containers/inline_var_len_entry_queue.h" ] 130 sources = [ "inline_var_len_entry_queue.c" ] 131 132 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 133 configs = [ "$dir_pw_build:conversion_warnings" ] 134} 135 136pw_source_set("vector") { 137 public_configs = [ ":public_include_path" ] 138 public_deps = [ 139 "$dir_pw_toolchain:constexpr_tag", 140 dir_pw_assert, 141 dir_pw_preprocessor, 142 ] 143 public = [ "public/pw_containers/vector.h" ] 144} 145 146pw_source_set("wrapped_iterator") { 147 public_configs = [ ":public_include_path" ] 148 public = [ "public/pw_containers/wrapped_iterator.h" ] 149} 150 151pw_source_set("intrusive_item") { 152 public_configs = [ ":public_include_path" ] 153 public = [ "public/pw_containers/internal/intrusive_item.h" ] 154 sources = [ "intrusive_item.cc" ] 155 deps = [ dir_pw_assert ] 156} 157 158pw_source_set("intrusive_list_common") { 159 public_configs = [ ":public_include_path" ] 160 public = [ 161 "public/pw_containers/internal/intrusive_list.h", 162 "public/pw_containers/internal/intrusive_list_item.h", 163 "public/pw_containers/internal/intrusive_list_iterator.h", 164 ] 165 public_deps = [ ":intrusive_item" ] 166} 167 168pw_source_set("intrusive_forward_list") { 169 public_configs = [ ":public_include_path" ] 170 public = [ "public/pw_containers/intrusive_forward_list.h" ] 171 public_deps = [ 172 ":config", 173 ":intrusive_list_common", 174 ] 175} 176 177pw_source_set("intrusive_list") { 178 public_configs = [ ":public_include_path" ] 179 public = [ "public/pw_containers/intrusive_list.h" ] 180 public_deps = [ 181 ":config", 182 ":intrusive_list_common", 183 ":legacy_intrusive_list", 184 ] 185} 186 187pw_source_set("legacy_intrusive_list") { 188 public_configs = [ ":public_include_path" ] 189 public = [ "public/pw_containers/internal/legacy_intrusive_list.h" ] 190 public_deps = [ ":intrusive_forward_list" ] 191 visibility = [ "./*" ] 192} 193 194pw_source_set("aa_tree") { 195 public_configs = [ ":public_include_path" ] 196 public = [ 197 "public/pw_containers/internal/aa_tree.h", 198 "public/pw_containers/internal/aa_tree_item.h", 199 "public/pw_containers/internal/aa_tree_iterator.h", 200 ] 201 public_deps = [ 202 ":intrusive_item", 203 "$dir_pw_bytes:packed_ptr", 204 dir_pw_assert, 205 dir_pw_function, 206 ] 207 sources = [ 208 "aa_tree.cc", 209 "aa_tree_item.cc", 210 ] 211 visibility = [ "./*" ] 212} 213 214pw_source_set("intrusive_map") { 215 public_configs = [ ":public_include_path" ] 216 public = [ "public/pw_containers/intrusive_map.h" ] 217 public_deps = [ ":aa_tree" ] 218} 219 220pw_source_set("intrusive_multimap") { 221 public_configs = [ ":public_include_path" ] 222 public = [ "public/pw_containers/intrusive_multimap.h" ] 223 public_deps = [ ":aa_tree" ] 224} 225 226pw_source_set("intrusive_set") { 227 public_configs = [ ":public_include_path" ] 228 public = [ "public/pw_containers/intrusive_set.h" ] 229 public_deps = [ ":aa_tree" ] 230} 231 232pw_source_set("intrusive_multiset") { 233 public_configs = [ ":public_include_path" ] 234 public = [ "public/pw_containers/intrusive_multiset.h" ] 235 public_deps = [ ":aa_tree" ] 236} 237 238pw_test_group("tests") { 239 tests = [ 240 ":algorithm_test", 241 ":filtered_view_test", 242 ":flat_map_test", 243 ":inline_deque_test", 244 ":inline_queue_test", 245 ":intrusive_forward_list_test", 246 ":intrusive_item_test", 247 ":intrusive_list_test", 248 ":intrusive_map_test", 249 ":intrusive_multimap_test", 250 ":intrusive_set_test", 251 ":intrusive_multiset_test", 252 ":raw_storage_test", 253 ":to_array_test", 254 ":inline_var_len_entry_queue_test", 255 ":vector_test", 256 ":wrapped_iterator_test", 257 ] 258 group_deps = [ "examples" ] 259} 260 261pw_test("algorithm_test") { 262 sources = [ "algorithm_test.cc" ] 263 deps = [ 264 ":algorithm", 265 ":flat_map", 266 ":intrusive_list", 267 ":vector", 268 dir_pw_span, 269 ] 270 271 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 272 configs = [ "$dir_pw_build:conversion_warnings" ] 273} 274 275pw_test("filtered_view_test") { 276 sources = [ "filtered_view_test.cc" ] 277 deps = [ 278 ":algorithm", 279 ":filtered_view", 280 ":flat_map", 281 ":intrusive_list", 282 dir_pw_span, 283 ] 284 285 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 286 configs = [ "$dir_pw_build:conversion_warnings" ] 287} 288 289pw_test("flat_map_test") { 290 sources = [ "flat_map_test.cc" ] 291 deps = [ 292 ":flat_map", 293 dir_pw_polyfill, 294 ] 295 296 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 297 configs = [ "$dir_pw_build:conversion_warnings" ] 298} 299 300pw_test("inline_deque_test") { 301 sources = [ "inline_deque_test.cc" ] 302 deps = [ 303 ":algorithm", 304 ":inline_deque", 305 ":test_helpers", 306 ] 307 negative_compilation_tests = true 308 309 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 310 configs = [ "$dir_pw_build:conversion_warnings" ] 311} 312 313pw_test("inline_queue_test") { 314 sources = [ "inline_queue_test.cc" ] 315 deps = [ 316 ":algorithm", 317 ":inline_queue", 318 ":test_helpers", 319 ] 320 negative_compilation_tests = true 321 322 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 323 configs = [ "$dir_pw_build:conversion_warnings" ] 324} 325 326pw_test("raw_storage_test") { 327 sources = [ "raw_storage_test.cc" ] 328 deps = [ 329 ":raw_storage", 330 ":test_helpers", 331 ] 332 333 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 334 configs = [ "$dir_pw_build:conversion_warnings" ] 335} 336 337pw_test("to_array_test") { 338 sources = [ "to_array_test.cc" ] 339 deps = [ ":to_array" ] 340 341 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 342 configs = [ "$dir_pw_build:conversion_warnings" ] 343} 344 345pw_test("inline_var_len_entry_queue_test") { 346 sources = [ 347 "inline_var_len_entry_queue_test.cc", 348 "pw_containers_private/inline_var_len_entry_queue_test_oracle.h", 349 ] 350 deps = [ 351 ":inline_var_len_entry_queue", 352 dir_pw_assert, 353 dir_pw_bytes, 354 ] 355 356 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 357 configs = [ "$dir_pw_build:conversion_warnings" ] 358} 359 360pw_test("vector_test") { 361 sources = [ "vector_test.cc" ] 362 deps = [ 363 ":test_helpers", 364 ":vector", 365 ] 366 367 negative_compilation_tests = true 368 369 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 370 configs = [ "$dir_pw_build:conversion_warnings" ] 371} 372 373pw_test("wrapped_iterator_test") { 374 sources = [ "wrapped_iterator_test.cc" ] 375 deps = [ ":wrapped_iterator" ] 376 377 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 378 configs = [ "$dir_pw_build:conversion_warnings" ] 379} 380 381pw_test("intrusive_forward_list_test") { 382 sources = [ "intrusive_forward_list_test.cc" ] 383 deps = [ 384 ":intrusive_forward_list", 385 ":vector", 386 ] 387 negative_compilation_tests = true 388 389 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 390 configs = [ "$dir_pw_build:conversion_warnings" ] 391} 392 393pw_test("intrusive_list_test") { 394 sources = [ "intrusive_list_test.cc" ] 395 deps = [ 396 ":intrusive_list", 397 ":vector", 398 ] 399 negative_compilation_tests = true 400 401 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 402 configs = [ "$dir_pw_build:conversion_warnings" ] 403} 404 405pw_test("intrusive_map_test") { 406 sources = [ "intrusive_map_test.cc" ] 407 deps = [ 408 ":intrusive_map", 409 ":intrusive_multimap", 410 dir_pw_span, 411 ] 412 negative_compilation_tests = true 413} 414 415pw_test("intrusive_multimap_test") { 416 sources = [ "intrusive_multimap_test.cc" ] 417 deps = [ 418 ":intrusive_map", 419 ":intrusive_multimap", 420 dir_pw_span, 421 ] 422 negative_compilation_tests = true 423} 424 425pw_test("intrusive_set_test") { 426 sources = [ "intrusive_set_test.cc" ] 427 deps = [ 428 ":intrusive_multiset", 429 ":intrusive_set", 430 dir_pw_span, 431 ] 432 negative_compilation_tests = true 433} 434 435pw_test("intrusive_multiset_test") { 436 sources = [ "intrusive_multiset_test.cc" ] 437 deps = [ 438 ":intrusive_multiset", 439 ":intrusive_set", 440 dir_pw_span, 441 ] 442 negative_compilation_tests = true 443} 444 445pw_test("intrusive_item_test") { 446 sources = [ "intrusive_item_test.cc" ] 447 deps = [ 448 ":intrusive_forward_list", 449 ":intrusive_list", 450 ":intrusive_map", 451 ":intrusive_multimap", 452 ":intrusive_multiset", 453 ":intrusive_set", 454 ] 455 negative_compilation_tests = true 456} 457 458pw_doc_group("docs") { 459 inputs = [ 460 "Kconfig", 461 "examples/flat_map.cc", 462 "examples/intrusive_forward_list.cc", 463 "examples/intrusive_list.cc", 464 "examples/intrusive_map.cc", 465 "examples/intrusive_multimap.cc", 466 "examples/intrusive_multiset.cc", 467 "examples/intrusive_set.cc", 468 "examples/multiple_containers.cc", 469 "examples/vector.cc", 470 "examples/wrapped_iterator.cc", 471 ] 472 sources = [ 473 "docs.rst", 474 "lists.rst", 475 "maps.rst", 476 "multiple_containers.rst", 477 "queues.rst", 478 "sets.rst", 479 "utilities.rst", 480 "vectors.rst", 481 ] 482 report_deps = [ 483 ":lists_size_report", 484 ":maps_size_report", 485 ":queues_size_report", 486 ":sets_size_report", 487 ":vectors_size_report", 488 ] 489} 490 491pw_size_diff("lists_size_report") { 492 title = "Sizes of Pigweed's list containers" 493 binaries = [ 494 { 495 base = "size_report:base" 496 target = "size_report:intrusive_list_base" 497 label = "IntrusiveList" 498 }, 499 { 500 base = "size_report:intrusive_list_base" 501 target = "size_report:intrusive_list_alternate_type" 502 label = "Additional IntrusiveList with different item type" 503 }, 504 { 505 base = "size_report:base" 506 target = "size_report:intrusive_forward_list_base" 507 label = "IntrusiveForwardList" 508 }, 509 { 510 base = "size_report:intrusive_forward_list_base" 511 target = "size_report:intrusive_forward_list_alternate_type" 512 label = "Additional IntrusiveForwardList with different item type" 513 }, 514 { 515 base = "size_report:base" 516 target = "size_report:intrusive_list_and_forward_list" 517 label = "IntrusiveForwardList and IntrusiveList" 518 }, 519 ] 520} 521 522pw_size_diff("maps_size_report") { 523 title = "Sizes of Pigweed's map containers" 524 binaries = [ 525 { 526 base = "size_report:base" 527 target = "size_report:flat_map_base" 528 label = "FlatMap" 529 }, 530 { 531 base = "size_report:flat_map_base" 532 target = "size_report:flat_map_alternate_types" 533 label = "Additional FlatMap with different key and value types" 534 }, 535 { 536 base = "size_report:base" 537 target = "size_report:intrusive_map_base" 538 label = "IntrusiveMap" 539 }, 540 { 541 base = "size_report:intrusive_map_base" 542 target = "size_report:intrusive_map_alternate_key" 543 label = "Additional IntrusiveMap with different key type" 544 }, 545 { 546 base = "size_report:intrusive_map_base" 547 target = "size_report:intrusive_map_alternate_types" 548 label = "Additional IntrusiveMap with different key and value types" 549 }, 550 { 551 base = "size_report:base" 552 target = "size_report:intrusive_multimap_base" 553 label = "IntrusiveMultiMap" 554 }, 555 { 556 base = "size_report:intrusive_multimap_base" 557 target = "size_report:intrusive_multimap_alternate_key" 558 label = "Additional IntrusiveMultiMap with different key type" 559 }, 560 { 561 base = "size_report:intrusive_multimap_base" 562 target = "size_report:intrusive_multimap_alternate_types" 563 label = "Additional IntrusiveMultiMap with different key and value types" 564 }, 565 { 566 base = "size_report:base" 567 target = "size_report:intrusive_map_and_multimap" 568 label = "IntrusiveMap and IntrusiveMultiMap" 569 }, 570 ] 571} 572 573pw_size_diff("queues_size_report") { 574 title = "Sizes of Pigweed's queue containers" 575 binaries = [ 576 { 577 base = "size_report:base" 578 target = "size_report:inline_deque_base" 579 label = "InlineDeque" 580 }, 581 { 582 base = "size_report:inline_deque_base" 583 target = "size_report:inline_deque_alternate_type" 584 label = "Additional InlineDeque with different item type" 585 }, 586 { 587 base = "size_report:base" 588 target = "size_report:inline_queue_base" 589 label = "InlineQueue" 590 }, 591 { 592 base = "size_report:inline_queue_base" 593 target = "size_report:inline_queue_alternate_type" 594 label = "Additional InlineQueue with different item type" 595 }, 596 { 597 base = "size_report:base" 598 target = "size_report:inline_deque_and_queue" 599 label = "InlineDeque and InlineQueue" 600 }, 601 ] 602} 603 604pw_size_diff("sets_size_report") { 605 title = "Sizes of Pigweed's set containers" 606 binaries = [ 607 { 608 base = "size_report:base" 609 target = "size_report:intrusive_set_base" 610 label = "IntrusiveSet" 611 }, 612 { 613 base = "size_report:intrusive_set_base" 614 target = "size_report:intrusive_set_alternate_type" 615 label = "Additional IntrusiveSet with different item type" 616 }, 617 { 618 base = "size_report:base" 619 target = "size_report:intrusive_multiset_base" 620 label = "IntrusiveMultiSet" 621 }, 622 { 623 base = "size_report:intrusive_multiset_base" 624 target = "size_report:intrusive_multiset_alternate_type" 625 label = "Additional IntrusiveMultiSet with different item type" 626 }, 627 { 628 base = "size_report:base" 629 target = "size_report:intrusive_set_and_multiset" 630 label = "IntrusiveSet and IntrusiveMultiSet" 631 }, 632 ] 633} 634 635pw_size_diff("vectors_size_report") { 636 title = "Size of Pigweed's vector container" 637 binaries = [ 638 { 639 base = "size_report:base" 640 target = "size_report:vector_base" 641 label = "Vector" 642 }, 643 { 644 base = "size_report:vector_base" 645 target = "size_report:vector_alternate_size" 646 label = "Additional Vector with the same item type but different size" 647 }, 648 { 649 base = "size_report:vector_base" 650 target = "size_report:vector_alternate_type" 651 label = "Additional Vector with different item type but same size" 652 }, 653 ] 654} 655