• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:block_allocator",
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:block_allocator",
106  ]
107  sources = [ "linker_sections.cc" ]
108}
109
110pw_test("metrics") {
111  deps = [
112    ":named_u32",
113    "$dir_pw_allocator:testing",
114    "$dir_pw_allocator:tracking_allocator",
115    dir_pw_tokenizer,
116  ]
117  sources = [ "metrics.cc" ]
118}
119
120pw_test("pmr") {
121  deps = [
122    "$dir_pw_allocator:allocator",
123    "$dir_pw_allocator:testing",
124  ]
125  sources = [ "pmr.cc" ]
126}
127
128pw_executable("size_report") {
129  check_includes = false
130  sources = [ "size_report.cc" ]
131  deps = [
132    ":custom_allocator",
133    "$dir_pw_allocator:block_allocator",
134    "$dir_pw_allocator:size_reporter",
135  ]
136}
137
138pw_test("spin_lock") {
139  enable_if = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != "" &&
140              pw_thread_TEST_THREAD_CONTEXT_BACKEND != ""
141  deps = [
142    ":named_u32",
143    "$dir_pw_allocator:synchronized_allocator",
144    "$dir_pw_allocator:testing",
145    "$dir_pw_sync:interrupt_spin_lock",
146    "$dir_pw_thread:test_thread_context",
147    "$dir_pw_thread:thread",
148    "$dir_pw_thread:thread_core",
149    dir_pw_assert,
150  ]
151  sources = [ "spin_lock.cc" ]
152}
153
154pw_test_group("examples") {
155  tests = [
156    ":basic",
157    ":block_allocator",
158    ":custom_allocator_test",
159    ":custom_allocator_perf_test",
160    ":linker_sections",
161    ":metrics",
162    ":pmr",
163    ":spin_lock",
164  ]
165}
166
167pw_size_diff("custom_allocator_size_report") {
168  title = "Example size report"
169  binaries = [
170    {
171      target = ":size_report"
172      base = "$dir_pw_allocator/size_report:first_fit_block_allocator"
173      label = "CustomAllocator"
174    },
175  ]
176}
177