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