1# Copyright 2024 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_perf_test/perf_test.gni") 19import("$dir_pw_sync/backend.gni") 20import("$dir_pw_thread/backend.gni") 21import("$dir_pw_unit_test/test.gni") 22 23# Libraries 24 25config("default_config") { 26 include_dirs = [ "public" ] 27 visibility = [ ":*" ] 28} 29 30pw_source_set("named_u32") { 31 public_configs = [ ":default_config" ] 32 public = [ "public/examples/named_u32.h" ] 33 public_deps = [ 34 dir_pw_bytes, 35 dir_pw_string, 36 ] 37} 38 39pw_source_set("custom_allocator") { 40 public_configs = [ ":default_config" ] 41 public = [ "public/examples/custom_allocator.h" ] 42 public_deps = [ dir_pw_allocator ] 43 sources = [ "custom_allocator.cc" ] 44 deps = [ 45 dir_pw_log, 46 dir_pw_result, 47 ] 48} 49 50pw_source_set("custom_allocator_test_harness") { 51 public_configs = [ ":default_config" ] 52 public = [ "public/examples/custom_allocator_test_harness.h" ] 53 public_deps = [ 54 ":custom_allocator", 55 "$dir_pw_allocator:test_harness", 56 "$dir_pw_allocator:testing", 57 ] 58} 59 60# Examples 61 62pw_test("basic") { 63 deps = [ 64 ":named_u32", 65 "$dir_pw_allocator:testing", 66 dir_pw_allocator, 67 ] 68 sources = [ "basic.cc" ] 69} 70 71pw_test("block_allocator") { 72 deps = [ 73 ":named_u32", 74 "$dir_pw_allocator:first_fit", 75 ] 76 sources = [ "block_allocator.cc" ] 77} 78 79pw_test("custom_allocator_perf_test") { 80 enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != "" 81 deps = [ 82 ":custom_allocator_test_harness", 83 "$dir_pw_perf_test:state", 84 dir_pw_perf_test, 85 dir_pw_random, 86 ] 87 sources = [ "custom_allocator_perf_test.cc" ] 88} 89 90pw_test("custom_allocator_test") { 91 deps = [ 92 ":custom_allocator", 93 ":custom_allocator_test_harness", 94 ":named_u32", 95 "$dir_pw_allocator:fuzzing", 96 "$dir_pw_allocator:testing", 97 "$dir_pw_containers:vector", 98 "$dir_pw_fuzzer:fuzztest", 99 ] 100 sources = [ "custom_allocator_test.cc" ] 101} 102 103pw_test("linker_sections") { 104 deps = [ 105 ":named_u32", 106 "$dir_pw_allocator:first_fit", 107 "$dir_pw_allocator:worst_fit", 108 "$dir_pw_allocator/block:detailed_block", 109 dir_pw_allocator, 110 ] 111 sources = [ "linker_sections.cc" ] 112} 113 114pw_test("metrics") { 115 deps = [ 116 ":named_u32", 117 "$dir_pw_allocator:metrics", 118 "$dir_pw_allocator:testing", 119 "$dir_pw_allocator:tracking_allocator", 120 dir_pw_tokenizer, 121 ] 122 sources = [ "metrics.cc" ] 123} 124 125pw_test("pmr") { 126 deps = [ 127 "$dir_pw_allocator:pmr_allocator", 128 "$dir_pw_allocator:testing", 129 dir_pw_allocator, 130 ] 131 sources = [ "pmr.cc" ] 132} 133 134pw_executable("size_report") { 135 check_includes = false 136 sources = [ "size_report.cc" ] 137 deps = [ 138 ":custom_allocator", 139 "$dir_pw_allocator:best_fit", 140 "$dir_pw_allocator/size_report:size_report", 141 "$dir_pw_bloat:bloat_this_binary", 142 ] 143} 144 145pw_test("spin_lock") { 146 enable_if = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != "" && 147 pw_thread_TEST_THREAD_CONTEXT_BACKEND != "" 148 deps = [ 149 ":named_u32", 150 "$dir_pw_allocator:synchronized_allocator", 151 "$dir_pw_allocator:testing", 152 "$dir_pw_sync:interrupt_spin_lock", 153 "$dir_pw_thread:test_thread_context", 154 "$dir_pw_thread:thread", 155 "$dir_pw_thread:thread_core", 156 dir_pw_assert, 157 ] 158 sources = [ "spin_lock.cc" ] 159} 160 161pw_test_group("examples") { 162 tests = [ 163 ":basic", 164 ":block_allocator", 165 ":custom_allocator_test", 166 ":custom_allocator_perf_test", 167 ":linker_sections", 168 ":metrics", 169 ":pmr", 170 ":spin_lock", 171 ] 172} 173 174pw_size_diff("custom_allocator_size_report") { 175 title = "Example size report" 176 binaries = [ 177 { 178 target = ":size_report" 179 base = "$dir_pw_allocator/size_report:best_fit" 180 label = "CustomAllocator" 181 }, 182 ] 183} 184