xref: /aosp_15_r20/external/pigweed/pw_multibuf/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2023 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_async2/backend.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("chunk") {
28  public_configs = [ ":public_include_path" ]
29  public = [ "public/pw_multibuf/chunk.h" ]
30  sources = [ "chunk.cc" ]
31  public_deps = [
32    "$dir_pw_sync:interrupt_spin_lock",
33    dir_pw_assert,
34    dir_pw_bytes,
35    dir_pw_preprocessor,
36    dir_pw_span,
37  ]
38  deps = [ "$dir_pw_assert:check" ]
39}
40
41pw_source_set("header_chunk_region_tracker") {
42  public_configs = [ ":public_include_path" ]
43  public = [ "public/pw_multibuf/header_chunk_region_tracker.h" ]
44  public_deps = [
45    ":chunk",
46    dir_pw_allocator,
47    dir_pw_bytes,
48  ]
49}
50
51pw_test("header_chunk_region_tracker_test") {
52  deps = [
53    ":chunk",
54    ":header_chunk_region_tracker",
55    "$dir_pw_allocator:testing",
56    dir_pw_status,
57  ]
58  sources = [ "header_chunk_region_tracker_test.cc" ]
59}
60
61pw_source_set("single_chunk_region_tracker") {
62  public_configs = [ ":public_include_path" ]
63  public = [ "public/pw_multibuf/single_chunk_region_tracker.h" ]
64  public_deps = [
65    ":chunk",
66    dir_pw_assert,
67    dir_pw_bytes,
68  ]
69}
70
71pw_test("single_chunk_region_tracker_test") {
72  deps = [
73    ":chunk",
74    ":single_chunk_region_tracker",
75  ]
76  sources = [ "single_chunk_region_tracker_test.cc" ]
77
78  # TODO: b/260624583 - Fix this for //targets/rp2040
79  enable_if = pw_build_EXECUTABLE_TARGET_TYPE != "pico_executable"
80}
81
82pw_test("chunk_test") {
83  deps = [
84    ":chunk",
85    ":header_chunk_region_tracker",
86    "$dir_pw_allocator:testing",
87  ]
88  sources = [ "chunk_test.cc" ]
89}
90
91pw_source_set("pw_multibuf") {
92  public_configs = [ ":public_include_path" ]
93  public = [ "public/pw_multibuf/multibuf.h" ]
94  sources = [ "multibuf.cc" ]
95  public_deps = [
96    ":chunk",
97    dir_pw_preprocessor,
98    dir_pw_status,
99  ]
100}
101
102pw_test("multibuf_test") {
103  deps = [
104    ":internal_test_utils",
105    ":pw_multibuf",
106    dir_pw_bytes,
107  ]
108  sources = [ "multibuf_test.cc" ]
109}
110
111pw_source_set("allocator") {
112  public_configs = [ ":public_include_path" ]
113  public = [ "public/pw_multibuf/allocator.h" ]
114  sources = [ "allocator.cc" ]
115  public_deps = [
116    ":pw_multibuf",
117    "$dir_pw_async2:dispatcher",
118    "$dir_pw_containers:intrusive_forward_list",
119    "$dir_pw_result",
120  ]
121}
122
123pw_test("allocator_test") {
124  enable_if = pw_async2_DISPATCHER_BACKEND != ""
125  deps = [
126    ":allocator",
127    "$dir_pw_async2:dispatcher",
128    "$dir_pw_async2:poll",
129  ]
130  sources = [ "allocator_test.cc" ]
131}
132
133pw_source_set("simple_allocator") {
134  public_configs = [ ":public_include_path" ]
135  public = [ "public/pw_multibuf/simple_allocator.h" ]
136  sources = [ "simple_allocator.cc" ]
137  public_deps = [
138    ":allocator",
139    ":pw_multibuf",
140    "$dir_pw_allocator:allocator",
141    "$dir_pw_containers:intrusive_list",
142  ]
143}
144
145pw_test("simple_allocator_test") {
146  enable_if = pw_async2_DISPATCHER_BACKEND != ""
147  deps = [
148    ":simple_allocator",
149    "$dir_pw_allocator:null_allocator",
150    "$dir_pw_allocator:testing",
151  ]
152  sources = [ "simple_allocator_test.cc" ]
153}
154
155pw_source_set("stream") {
156  public_configs = [ ":public_include_path" ]
157  public = [ "public/pw_multibuf/stream.h" ]
158  public_deps = [
159    ":pw_multibuf",
160    dir_pw_status,
161    dir_pw_stream,
162  ]
163  sources = [ "stream.cc" ]
164}
165
166pw_test("stream_test") {
167  enable_if = pw_async2_DISPATCHER_BACKEND != ""
168  deps = [
169    ":internal_test_utils",
170    ":stream",
171  ]
172  sources = [ "stream_test.cc" ]
173}
174
175pw_source_set("from_span") {
176  public_configs = [ ":public_include_path" ]
177  public = [ "public/pw_multibuf/from_span.h" ]
178  public_deps = [
179    ":pw_multibuf",
180    dir_pw_allocator,
181    dir_pw_function,
182  ]
183  sources = [ "from_span.cc" ]
184}
185
186pw_test("from_span_test") {
187  deps = [
188    ":from_span",
189    "$dir_pw_allocator:testing",
190  ]
191  sources = [ "from_span_test.cc" ]
192}
193
194pw_source_set("testing") {
195  public_configs = [ ":public_include_path" ]
196  public = [ "public/pw_multibuf/simple_allocator_for_test.h" ]
197  public_deps = [
198    ":simple_allocator",
199    "$dir_pw_allocator:testing",
200    dir_pw_assert,
201  ]
202}
203
204pw_source_set("internal_test_utils") {
205  sources = [ "pw_multibuf_private/test_utils.h" ]
206  public_deps = [
207    ":header_chunk_region_tracker",
208    ":pw_multibuf",
209    "$dir_pw_allocator:testing",
210    dir_pw_assert,
211    dir_pw_bytes,
212  ]
213  visibility = [ ":*" ]
214}
215
216pw_test_group("tests") {
217  tests = [
218    ":allocator_test",
219    ":chunk_test",
220    ":from_span_test",
221    ":header_chunk_region_tracker_test",
222    ":multibuf_test",
223    ":simple_allocator_test",
224    ":single_chunk_region_tracker_test",
225    ":stream_test",
226  ]
227}
228
229pw_doc_group("docs") {
230  sources = [ "docs.rst" ]
231}
232