xref: /aosp_15_r20/external/pigweed/pw_containers/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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_assert,
85    dir_pw_preprocessor,
86    dir_pw_span,
87  ]
88  public = [ "public/pw_containers/inline_deque.h" ]
89}
90
91pw_source_set("inline_queue") {
92  public_configs = [ ":public_include_path" ]
93  public_deps = [ ":inline_deque" ]
94  public = [ "public/pw_containers/inline_queue.h" ]
95}
96
97pw_source_set("iterator") {
98  public_configs = [ ":public_include_path" ]
99  public_deps = [ dir_pw_polyfill ]
100  public = [ "public/pw_containers/iterator.h" ]
101}
102
103pw_source_set("raw_storage") {
104  public_configs = [ ":public_include_path" ]
105  public = [ "public/pw_containers/internal/raw_storage.h" ]
106  visibility = [ ":*" ]
107}
108
109pw_source_set("test_helpers") {
110  public = [ "pw_containers_private/test_helpers.h" ]
111  sources = [ "test_helpers.cc" ]
112  visibility = [ ":*" ]
113}
114
115pw_source_set("to_array") {
116  public_configs = [ ":public_include_path" ]
117  public = [ "public/pw_containers/to_array.h" ]
118}
119
120pw_source_set("inline_var_len_entry_queue") {
121  public_configs = [ ":public_include_path" ]
122  public_deps = [ dir_pw_varint ]
123  deps = [ dir_pw_assert ]
124  public = [ "public/pw_containers/inline_var_len_entry_queue.h" ]
125  sources = [ "inline_var_len_entry_queue.c" ]
126
127  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
128  configs = [ "$dir_pw_build:conversion_warnings" ]
129}
130
131pw_source_set("vector") {
132  public_configs = [ ":public_include_path" ]
133  public_deps = [
134    dir_pw_assert,
135    dir_pw_preprocessor,
136  ]
137  public = [ "public/pw_containers/vector.h" ]
138}
139
140pw_source_set("wrapped_iterator") {
141  public_configs = [ ":public_include_path" ]
142  public = [ "public/pw_containers/wrapped_iterator.h" ]
143}
144
145pw_source_set("intrusive_item") {
146  public_configs = [ ":public_include_path" ]
147  public = [ "public/pw_containers/internal/intrusive_item.h" ]
148  sources = [ "intrusive_item.cc" ]
149  deps = [ dir_pw_assert ]
150}
151
152pw_source_set("intrusive_list_common") {
153  public_configs = [ ":public_include_path" ]
154  public = [
155    "public/pw_containers/internal/intrusive_list.h",
156    "public/pw_containers/internal/intrusive_list_item.h",
157    "public/pw_containers/internal/intrusive_list_iterator.h",
158  ]
159  public_deps = [ ":intrusive_item" ]
160}
161
162pw_source_set("intrusive_forward_list") {
163  public_configs = [ ":public_include_path" ]
164  public = [ "public/pw_containers/intrusive_forward_list.h" ]
165  public_deps = [
166    ":config",
167    ":intrusive_list_common",
168  ]
169}
170
171pw_source_set("intrusive_list") {
172  public_configs = [ ":public_include_path" ]
173  public = [ "public/pw_containers/intrusive_list.h" ]
174  public_deps = [
175    ":config",
176    ":intrusive_list_common",
177    ":legacy_intrusive_list",
178  ]
179}
180
181pw_source_set("legacy_intrusive_list") {
182  public_configs = [ ":public_include_path" ]
183  public = [ "public/pw_containers/internal/legacy_intrusive_list.h" ]
184  public_deps = [ ":intrusive_forward_list" ]
185  visibility = [ "./*" ]
186}
187
188pw_source_set("aa_tree") {
189  public_configs = [ ":public_include_path" ]
190  public = [
191    "public/pw_containers/internal/aa_tree.h",
192    "public/pw_containers/internal/aa_tree_item.h",
193    "public/pw_containers/internal/aa_tree_iterator.h",
194  ]
195  public_deps = [
196    ":intrusive_item",
197    "$dir_pw_bytes:packed_ptr",
198    dir_pw_assert,
199    dir_pw_function,
200  ]
201  sources = [
202    "aa_tree.cc",
203    "aa_tree_item.cc",
204  ]
205  visibility = [ "./*" ]
206}
207
208pw_source_set("intrusive_map") {
209  public_configs = [ ":public_include_path" ]
210  public = [ "public/pw_containers/intrusive_map.h" ]
211  public_deps = [ ":aa_tree" ]
212}
213
214pw_source_set("intrusive_multimap") {
215  public_configs = [ ":public_include_path" ]
216  public = [ "public/pw_containers/intrusive_multimap.h" ]
217  public_deps = [ ":aa_tree" ]
218}
219
220pw_source_set("intrusive_set") {
221  public_configs = [ ":public_include_path" ]
222  public = [ "public/pw_containers/intrusive_set.h" ]
223  public_deps = [ ":aa_tree" ]
224}
225
226pw_source_set("intrusive_multiset") {
227  public_configs = [ ":public_include_path" ]
228  public = [ "public/pw_containers/intrusive_multiset.h" ]
229  public_deps = [ ":aa_tree" ]
230}
231
232pw_test_group("tests") {
233  tests = [
234    ":algorithm_test",
235    ":filtered_view_test",
236    ":flat_map_test",
237    ":inline_deque_test",
238    ":inline_queue_test",
239    ":intrusive_forward_list_test",
240    ":intrusive_item_test",
241    ":intrusive_list_test",
242    ":intrusive_map_test",
243    ":intrusive_multimap_test",
244    ":intrusive_set_test",
245    ":intrusive_multiset_test",
246    ":raw_storage_test",
247    ":to_array_test",
248    ":inline_var_len_entry_queue_test",
249    ":vector_test",
250    ":wrapped_iterator_test",
251  ]
252  group_deps = [ "examples" ]
253}
254
255pw_test("algorithm_test") {
256  sources = [ "algorithm_test.cc" ]
257  deps = [
258    ":algorithm",
259    ":flat_map",
260    ":intrusive_list",
261    ":vector",
262    dir_pw_span,
263  ]
264
265  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
266  configs = [ "$dir_pw_build:conversion_warnings" ]
267}
268
269pw_test("filtered_view_test") {
270  sources = [ "filtered_view_test.cc" ]
271  deps = [
272    ":algorithm",
273    ":filtered_view",
274    ":flat_map",
275    ":intrusive_list",
276    dir_pw_span,
277  ]
278
279  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
280  configs = [ "$dir_pw_build:conversion_warnings" ]
281}
282
283pw_test("flat_map_test") {
284  sources = [ "flat_map_test.cc" ]
285  deps = [
286    ":flat_map",
287    dir_pw_polyfill,
288  ]
289
290  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
291  configs = [ "$dir_pw_build:conversion_warnings" ]
292}
293
294pw_test("inline_deque_test") {
295  sources = [ "inline_deque_test.cc" ]
296  deps = [
297    ":algorithm",
298    ":inline_deque",
299    ":test_helpers",
300  ]
301  negative_compilation_tests = true
302
303  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
304  configs = [ "$dir_pw_build:conversion_warnings" ]
305}
306
307pw_test("inline_queue_test") {
308  sources = [ "inline_queue_test.cc" ]
309  deps = [
310    ":algorithm",
311    ":inline_queue",
312    ":test_helpers",
313  ]
314  negative_compilation_tests = true
315
316  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
317  configs = [ "$dir_pw_build:conversion_warnings" ]
318}
319
320pw_test("raw_storage_test") {
321  sources = [ "raw_storage_test.cc" ]
322  deps = [
323    ":raw_storage",
324    ":test_helpers",
325  ]
326
327  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
328  configs = [ "$dir_pw_build:conversion_warnings" ]
329}
330
331pw_test("to_array_test") {
332  sources = [ "to_array_test.cc" ]
333  deps = [ ":to_array" ]
334
335  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
336  configs = [ "$dir_pw_build:conversion_warnings" ]
337}
338
339pw_test("inline_var_len_entry_queue_test") {
340  sources = [
341    "inline_var_len_entry_queue_test.cc",
342    "pw_containers_private/inline_var_len_entry_queue_test_oracle.h",
343  ]
344  deps = [
345    ":inline_var_len_entry_queue",
346    dir_pw_assert,
347    dir_pw_bytes,
348  ]
349
350  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
351  configs = [ "$dir_pw_build:conversion_warnings" ]
352}
353
354pw_test("vector_test") {
355  sources = [ "vector_test.cc" ]
356  deps = [
357    ":test_helpers",
358    ":vector",
359  ]
360
361  negative_compilation_tests = true
362
363  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
364  configs = [ "$dir_pw_build:conversion_warnings" ]
365}
366
367pw_test("wrapped_iterator_test") {
368  sources = [ "wrapped_iterator_test.cc" ]
369  deps = [ ":wrapped_iterator" ]
370
371  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
372  configs = [ "$dir_pw_build:conversion_warnings" ]
373}
374
375pw_test("intrusive_forward_list_test") {
376  sources = [ "intrusive_forward_list_test.cc" ]
377  deps = [
378    ":intrusive_forward_list",
379    ":vector",
380  ]
381  negative_compilation_tests = true
382
383  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
384  configs = [ "$dir_pw_build:conversion_warnings" ]
385}
386
387pw_test("intrusive_list_test") {
388  sources = [ "intrusive_list_test.cc" ]
389  deps = [
390    ":intrusive_list",
391    ":vector",
392  ]
393  negative_compilation_tests = true
394
395  # TODO: b/259746255 - Remove this when everything compiles with -Wconversion.
396  configs = [ "$dir_pw_build:conversion_warnings" ]
397}
398
399pw_test("intrusive_map_test") {
400  sources = [ "intrusive_map_test.cc" ]
401  deps = [
402    ":intrusive_map",
403    ":intrusive_multimap",
404    dir_pw_span,
405  ]
406  negative_compilation_tests = true
407}
408
409pw_test("intrusive_multimap_test") {
410  sources = [ "intrusive_multimap_test.cc" ]
411  deps = [
412    ":intrusive_map",
413    ":intrusive_multimap",
414    dir_pw_span,
415  ]
416  negative_compilation_tests = true
417}
418
419pw_test("intrusive_set_test") {
420  sources = [ "intrusive_set_test.cc" ]
421  deps = [
422    ":intrusive_multiset",
423    ":intrusive_set",
424    dir_pw_span,
425  ]
426  negative_compilation_tests = true
427}
428
429pw_test("intrusive_multiset_test") {
430  sources = [ "intrusive_multiset_test.cc" ]
431  deps = [
432    ":intrusive_multiset",
433    ":intrusive_set",
434    dir_pw_span,
435  ]
436  negative_compilation_tests = true
437}
438
439pw_test("intrusive_item_test") {
440  sources = [ "intrusive_item_test.cc" ]
441  deps = [
442    ":intrusive_forward_list",
443    ":intrusive_list",
444    ":intrusive_map",
445    ":intrusive_multimap",
446    ":intrusive_multiset",
447    ":intrusive_set",
448  ]
449  negative_compilation_tests = true
450}
451
452pw_doc_group("docs") {
453  inputs = [
454    "Kconfig",
455    "examples/flat_map.cc",
456    "examples/intrusive_forward_list.cc",
457    "examples/intrusive_list.cc",
458    "examples/intrusive_map.cc",
459    "examples/intrusive_multimap.cc",
460    "examples/intrusive_multiset.cc",
461    "examples/intrusive_set.cc",
462    "examples/multiple_containers.cc",
463    "examples/wrapped_iterator.cc",
464  ]
465  sources = [ "docs.rst" ]
466  report_deps = [ ":intrusive_list_size_report" ]
467}
468
469pw_size_diff("intrusive_list_size_report") {
470  title = "Pigweed containers size report"
471  binaries = [
472    {
473      target = "size_report:linked_list_one_item"
474      base = "size_report:base"
475      label = "linked list one item"
476    },
477    {
478      target = "size_report:linked_list_two_item"
479      base = "size_report:base"
480      label = "linked list two item"
481    },
482    {
483      target = "size_report:linked_list_four_item"
484      base = "size_report:base"
485      label = "linked list four item"
486    },
487    {
488      target = "size_report:intrusive_forward_list_one_item"
489      base = "size_report:base"
490      label = "intrusive list one item"
491    },
492    {
493      target = "size_report:intrusive_forward_list_two_item"
494      base = "size_report:base"
495      label = "intrusive list two item"
496    },
497    {
498      target = "size_report:intrusive_forward_list_four_item"
499      base = "size_report:base"
500      label = "intrusive list four item"
501    },
502  ]
503}
504