• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  ]
99}
100
101pw_test("multibuf_test") {
102  deps = [
103    ":internal_test_utils",
104    ":pw_multibuf",
105  ]
106  sources = [ "multibuf_test.cc" ]
107}
108
109pw_source_set("allocator") {
110  public_configs = [ ":public_include_path" ]
111  public = [ "public/pw_multibuf/allocator.h" ]
112  sources = [ "allocator.cc" ]
113  public_deps = [
114    ":pw_multibuf",
115    "$dir_pw_async2:dispatcher",
116    "$dir_pw_result",
117  ]
118}
119
120pw_test("allocator_test") {
121  enable_if = pw_async2_DISPATCHER_BACKEND != ""
122  deps = [
123    ":allocator",
124    "$dir_pw_async2:dispatcher",
125    "$dir_pw_async2:poll",
126  ]
127  sources = [ "allocator_test.cc" ]
128}
129
130pw_source_set("simple_allocator") {
131  public_configs = [ ":public_include_path" ]
132  public = [ "public/pw_multibuf/simple_allocator.h" ]
133  sources = [ "simple_allocator.cc" ]
134  public_deps = [
135    ":allocator",
136    ":pw_multibuf",
137    "$dir_pw_allocator:allocator",
138    "$dir_pw_containers:intrusive_list",
139  ]
140}
141
142pw_test("simple_allocator_test") {
143  enable_if = pw_async2_DISPATCHER_BACKEND != ""
144  deps = [
145    ":simple_allocator",
146    "$dir_pw_allocator:null_allocator",
147    "$dir_pw_allocator:testing",
148  ]
149  sources = [ "simple_allocator_test.cc" ]
150}
151
152pw_source_set("stream") {
153  public_configs = [ ":public_include_path" ]
154  public = [ "public/pw_multibuf/stream.h" ]
155  public_deps = [
156    ":pw_multibuf",
157    dir_pw_status,
158    dir_pw_stream,
159  ]
160  sources = [ "stream.cc" ]
161}
162
163pw_test("stream_test") {
164  enable_if = pw_async2_DISPATCHER_BACKEND != ""
165  deps = [
166    ":internal_test_utils",
167    ":stream",
168  ]
169  sources = [ "stream_test.cc" ]
170}
171
172pw_source_set("testing") {
173  public_configs = [ ":public_include_path" ]
174  public = [ "public/pw_multibuf/simple_allocator_for_test.h" ]
175  public_deps = [
176    ":simple_allocator",
177    "$dir_pw_allocator:testing",
178    dir_pw_assert,
179  ]
180}
181
182pw_source_set("internal_test_utils") {
183  sources = [ "pw_multibuf_private/test_utils.h" ]
184  public_deps = [
185    ":header_chunk_region_tracker",
186    ":pw_multibuf",
187    "$dir_pw_allocator:testing",
188    dir_pw_assert,
189    dir_pw_bytes,
190  ]
191  visibility = [ ":*" ]
192}
193
194pw_test_group("tests") {
195  tests = [
196    ":allocator_test",
197    ":chunk_test",
198    ":header_chunk_region_tracker_test",
199    ":multibuf_test",
200    ":simple_allocator_test",
201    ":single_chunk_region_tracker_test",
202    ":stream_test",
203  ]
204}
205
206pw_doc_group("docs") {
207  sources = [ "docs.rst" ]
208}
209