xref: /aosp_15_r20/external/pigweed/pw_bytes/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2021 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/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_unit_test/test.gni")
21
22config("public_include_path") {
23  include_dirs = [ "public" ]
24  visibility = [ ":*" ]
25}
26
27pw_source_set("pw_bytes") {
28  public_configs = [ ":public_include_path" ]
29  public = [
30    "public/pw_bytes/array.h",
31    "public/pw_bytes/byte_builder.h",
32    "public/pw_bytes/endian.h",
33    "public/pw_bytes/span.h",
34    "public/pw_bytes/suffix.h",
35    "public/pw_bytes/units.h",
36  ]
37  sources = [ "byte_builder.cc" ]
38  public_deps = [
39    "$dir_pw_bytes:bit",
40    "$dir_pw_containers:iterator",
41    dir_pw_preprocessor,
42    dir_pw_span,
43    dir_pw_status,
44  ]
45}
46
47pw_source_set("alignment") {
48  public_configs = [ ":public_include_path" ]
49  public = [ "public/pw_bytes/alignment.h" ]
50  public_deps = [
51    ":pw_bytes",
52    "$dir_pw_third_party/fuchsia:stdcompat",
53    dir_pw_assert,
54    dir_pw_preprocessor,
55  ]
56  sources = [ "alignment.cc" ]
57}
58
59pw_source_set("bit") {
60  public_configs = [ ":public_include_path" ]
61  public = [ "public/pw_bytes/bit.h" ]
62  public_deps = [ "$dir_pw_third_party/fuchsia:stdcompat" ]
63}
64
65pw_source_set("packed_ptr") {
66  public_configs = [ ":public_include_path" ]
67  public = [ "public/pw_bytes/packed_ptr.h" ]
68  public_deps = [
69    "$dir_pw_third_party/fuchsia:stdcompat",
70    dir_pw_assert,
71  ]
72}
73
74pw_test_group("tests") {
75  tests = [
76    ":alignment_test",
77    ":array_test",
78    ":bit_test",
79    ":byte_builder_test",
80    ":endian_test",
81    ":packed_ptr_test",
82    ":suffix_test",
83    ":units_test",
84  ]
85  group_deps = [
86    "$dir_pw_preprocessor:tests",
87    "$dir_pw_status:tests",
88  ]
89}
90
91pw_test("alignment_test") {
92  deps = [ ":alignment" ]
93  sources = [ "alignment_test.cc" ]
94}
95
96pw_test("array_test") {
97  deps = [ ":pw_bytes" ]
98  sources = [ "array_test.cc" ]
99}
100
101pw_test("bit_test") {
102  deps = [ ":bit" ]
103  sources = [ "bit_test.cc" ]
104}
105
106pw_test("byte_builder_test") {
107  deps = [ ":pw_bytes" ]
108  sources = [ "byte_builder_test.cc" ]
109}
110
111pw_test("endian_test") {
112  deps = [ ":pw_bytes" ]
113  sources = [ "endian_test.cc" ]
114}
115
116pw_test("packed_ptr_test") {
117  deps = [ ":packed_ptr" ]
118  sources = [ "packed_ptr_test.cc" ]
119  negative_compilation_tests = true
120}
121
122pw_test("suffix_test") {
123  deps = [ ":pw_bytes" ]
124  sources = [ "suffix_test.cc" ]
125  negative_compilation_tests = true
126}
127
128pw_test("units_test") {
129  deps = [ ":pw_bytes" ]
130  sources = [ "units_test.cc" ]
131}
132
133pw_doc_group("docs") {
134  inputs = [ "Kconfig" ]
135  sources = [ "docs.rst" ]
136  report_deps = [ ":byte_builder_size_report" ]
137}
138
139pw_size_diff("byte_builder_size_report") {
140  title = "Using pw::ByteBuilder"
141
142  binaries = [
143    {
144      target = "size_report:with_byte_builder"
145      base = "size_report:without_byte_builder"
146      label = "Using ByteBuilder vs not using it"
147    },
148  ]
149}
150