• 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
15load("@rules_cc//cc:cc_library.bzl", "cc_library")
16load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
17
18package(default_visibility = ["//visibility:public"])
19
20licenses(["notice"])
21
22cc_library(
23    name = "result",
24    hdrs = ["public/pw_allocator/block/result.h"],
25    strip_include_prefix = "public",
26    deps = [
27        "//pw_allocator:hardening",
28        "//pw_assert:assert",
29        "//pw_status",
30    ],
31)
32
33# Block mixins
34
35cc_library(
36    name = "alignable",
37    hdrs = ["public/pw_allocator/block/alignable.h"],
38    strip_include_prefix = "public",
39    deps = [
40        ":allocatable",
41        "//pw_allocator",
42        "//pw_allocator:hardening",
43        "//pw_bytes:alignment",
44        "//pw_status",
45        "//third_party/fuchsia:stdcompat",
46    ],
47)
48
49cc_library(
50    name = "allocatable",
51    hdrs = ["public/pw_allocator/block/allocatable.h"],
52    strip_include_prefix = "public",
53    deps = [
54        ":contiguous",
55        ":result",
56        "//pw_allocator",
57        "//pw_allocator:hardening",
58        "//pw_bytes:alignment",
59        "//pw_status",
60    ],
61)
62
63cc_library(
64    name = "basic",
65    srcs = ["basic.cc"],
66    hdrs = ["public/pw_allocator/block/basic.h"],
67    implementation_deps = ["//pw_assert:check"],
68    strip_include_prefix = "public",
69    deps = [
70        "//pw_allocator:hardening",
71        "//pw_bytes:alignment",
72        "//pw_result",
73        "//pw_status",
74        "//third_party/fuchsia:stdcompat",
75    ],
76)
77
78cc_library(
79    name = "contiguous",
80    srcs = ["contiguous.cc"],
81    hdrs = ["public/pw_allocator/block/contiguous.h"],
82    implementation_deps = ["//pw_assert:check"],
83    strip_include_prefix = "public",
84    deps = [
85        ":basic",
86        "//pw_allocator:hardening",
87        "//pw_bytes",
88        "//third_party/fuchsia:stdcompat",
89    ],
90)
91
92cc_library(
93    name = "iterable",
94    hdrs = ["public/pw_allocator/block/iterable.h"],
95    strip_include_prefix = "public",
96    deps = [
97        ":contiguous",
98    ],
99)
100
101cc_library(
102    name = "poisonable",
103    srcs = ["poisonable.cc"],
104    hdrs = ["public/pw_allocator/block/poisonable.h"],
105    implementation_deps = ["//pw_assert:check"],
106    strip_include_prefix = "public",
107    deps = [
108        ":contiguous",
109        "//pw_allocator:config",
110        "//pw_allocator:hardening",
111        "//third_party/fuchsia:stdcompat",
112    ],
113)
114
115cc_library(
116    name = "with_layout",
117    hdrs = ["public/pw_allocator/block/with_layout.h"],
118    strip_include_prefix = "public",
119    deps = [
120        ":alignable",
121        "//pw_allocator",
122        "//pw_allocator:hardening",
123        "//pw_assert:assert",
124    ],
125)
126
127# Block implementations
128
129cc_library(
130    name = "detailed_block",
131    hdrs = ["public/pw_allocator/block/detailed_block.h"],
132    strip_include_prefix = "public",
133    deps = [
134        ":alignable",
135        ":allocatable",
136        ":basic",
137        ":contiguous",
138        ":iterable",
139        ":poisonable",
140        ":with_layout",
141        "//pw_allocator",
142        "//pw_allocator:hardening",
143        "//pw_assert:assert",
144        "//pw_bytes",
145        "//pw_status",
146    ],
147)
148
149cc_library(
150    name = "small_block_base",
151    hdrs = ["public/pw_allocator/block/small_block_base.h"],
152    strip_include_prefix = "public",
153    deps = [
154        ":allocatable",
155        ":basic",
156        ":contiguous",
157        ":iterable",
158        "//pw_allocator/bucket:fast_sorted",
159        "//pw_bytes",
160    ],
161)
162
163cc_library(
164    name = "small_block",
165    hdrs = ["public/pw_allocator/block/small_block.h"],
166    strip_include_prefix = "public",
167    deps = [":small_block_base"],
168)
169
170cc_library(
171    name = "small_alignable_block",
172    hdrs = ["public/pw_allocator/block/small_alignable_block.h"],
173    strip_include_prefix = "public",
174    deps = [
175        ":alignable",
176        ":small_block_base",
177    ],
178)
179
180cc_library(
181    name = "tiny_block",
182    hdrs = ["public/pw_allocator/block/tiny_block.h"],
183    strip_include_prefix = "public",
184    deps = [":small_block_base"],
185)
186
187# Testing
188
189cc_library(
190    name = "testing",
191    testonly = True,
192    hdrs = [
193        "public/pw_allocator/block/testing.h",
194        "public/pw_allocator/block/unit_tests.h",
195    ],
196    strip_include_prefix = "public",
197    deps = [
198        ":allocatable",
199        ":result",
200        "//pw_allocator:testing",
201        "//pw_assert:assert",
202        "//pw_bytes:alignment",
203        "//pw_status",
204        "//third_party/fuchsia:stdcompat",
205    ],
206)
207
208pw_cc_test(
209    name = "result_test",
210    srcs = ["result_test.cc"],
211    deps = [
212        ":basic",
213        ":result",
214        "//pw_status",
215    ],
216)
217
218pw_cc_test(
219    name = "detailed_block_test",
220    srcs = ["detailed_block_test.cc"],
221    deps = [
222        ":detailed_block",
223        ":testing",
224        "//pw_unit_test",
225    ],
226)
227
228pw_cc_test(
229    name = "small_block_test",
230    srcs = ["small_block_test.cc"],
231    deps = [
232        ":small_block",
233        ":testing",
234        "//pw_unit_test",
235    ],
236)
237
238pw_cc_test(
239    name = "small_alignable_block_test",
240    srcs = ["small_alignable_block_test.cc"],
241    deps = [
242        ":small_alignable_block",
243        ":testing",
244        "//pw_unit_test",
245    ],
246)
247
248pw_cc_test(
249    name = "tiny_block_test",
250    srcs = ["tiny_block_test.cc"],
251    deps = [
252        ":testing",
253        ":tiny_block",
254        "//pw_unit_test",
255    ],
256)
257
258filegroup(
259    name = "doxygen",
260    srcs = [
261        "public/pw_allocator/block/alignable.h",
262        "public/pw_allocator/block/allocatable.h",
263        "public/pw_allocator/block/basic.h",
264        "public/pw_allocator/block/contiguous.h",
265        "public/pw_allocator/block/detailed_block.h",
266        "public/pw_allocator/block/iterable.h",
267        "public/pw_allocator/block/poisonable.h",
268        "public/pw_allocator/block/result.h",
269        "public/pw_allocator/block/small_alignable_block.h",
270        "public/pw_allocator/block/small_block.h",
271        "public/pw_allocator/block/tiny_block.h",
272        "public/pw_allocator/block/with_layout.h",
273    ],
274)
275