Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_kvs / BUILD.gn
1 # Copyright 2020 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
15 import("//build_overrides/pigweed.gni")
16
17 import("$dir_pw_bloat/bloat.gni")
18 import("$dir_pw_build/module_config.gni")
19 import("$dir_pw_build/target_types.gni")
20 import("$dir_pw_docgen/docs.gni")
21 import("$dir_pw_unit_test/test.gni")
22
23 declare_args() {
24   # The build target that overrides the default configuration options for this
25   # module. This should point to a source set that provides defines through a
26   # public config (which may -include a file or add defines directly).
27   pw_kvs_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
28 }
29
30 config("public_include_path") {
31   include_dirs = [ "public" ]
32   visibility = [ ":*" ]
33 }
34
35 pw_source_set("pw_kvs") {
36   public_configs = [ ":public_include_path" ]
37   public = [
38     "public/pw_kvs/alignment.h",
39     "public/pw_kvs/checksum.h",
40     "public/pw_kvs/flash_memory.h",
41     "public/pw_kvs/flash_test_partition.h",
42     "public/pw_kvs/format.h",
43     "public/pw_kvs/io.h",
44     "public/pw_kvs/key.h",
45     "public/pw_kvs/key_value_store.h",
46   ]
47   sources = [
48     "alignment.cc",
49     "checksum.cc",
50     "entry.cc",
51     "entry_cache.cc",
52     "flash_memory.cc",
53     "format.cc",
54     "key_value_store.cc",
55     "public/pw_kvs/internal/entry.h",
56     "public/pw_kvs/internal/entry_cache.h",
57     "public/pw_kvs/internal/hash.h",
58     "public/pw_kvs/internal/key_descriptor.h",
59     "public/pw_kvs/internal/sectors.h",
60     "public/pw_kvs/internal/span_traits.h",
61     "sectors.cc",
62   ]
63   public_deps = [
64     dir_pw_assert,
65     dir_pw_bytes,
66     dir_pw_containers,
67     dir_pw_status,
68     dir_pw_string,
69   ]
70   deps = [
71     ":config",
72     dir_pw_checksum,
73     dir_pw_log,
74   ]
75   friend = [ ":*" ]
76 }
77
78 pw_source_set("config") {
79   public_deps = [ pw_kvs_CONFIG ]
80   public = [ "pw_kvs_private/config.h" ]
81   visibility = [ ":*" ]
82 }
83
84 pw_source_set("crc16") {
85   public = [ "public/pw_kvs/crc16_checksum.h" ]
86   public_deps = [
87     ":pw_kvs",
88     dir_pw_checksum,
89   ]
90 }
91
92 pw_source_set("flash_test_partition") {
93   public = [ "public/pw_kvs/flash_test_partition.h" ]
94   public_deps = [ ":pw_kvs" ]
95 }
96
97 pw_source_set("test_key_value_store") {
98   public = [ "public/pw_kvs/test_key_value_store.h" ]
99   public_deps = [ ":pw_kvs" ]
100 }
101
102 pw_source_set("fake_flash") {
103   public_configs = [ ":public_include_path" ]
104   public = [ "public/pw_kvs/fake_flash_memory.h" ]
105   sources = [ "fake_flash_memory.cc" ]
106   public_deps = [
107     dir_pw_containers,
108     dir_pw_kvs,
109     dir_pw_status,
110   ]
111   deps = [
112     ":config",
113     dir_pw_log,
114   ]
115 }
116
117 pw_source_set("fake_flash_small_partition") {
118   public_configs = [ ":public_include_path" ]
119   public = [ "public/pw_kvs/flash_test_partition.h" ]
120   sources = [ "fake_flash_test_partition.cc" ]
121   public_deps = [ ":flash_test_partition" ]
122   deps = [
123     ":fake_flash",
124     dir_pw_kvs,
125   ]
126 }
127
128 pw_source_set("fake_flash_12_byte_partition") {
129   public_configs = [ ":public_include_path" ]
130   public = [ "public/pw_kvs/flash_test_partition.h" ]
131   sources = [ "fake_flash_test_partition.cc" ]
132   public_deps = [ ":flash_test_partition" ]
133   deps = [
134     ":fake_flash",
135     dir_pw_kvs,
136   ]
137   defines = [
138     "PW_FLASH_TEST_SECTORS=3",
139     "PW_FLASH_TEST_SECTOR_SIZE=4",
140     "PW_FLASH_TEST_ALIGNMENT=4",
141   ]
142 }
143
144 pw_source_set("fake_flash_64_aligned_partition") {
145   public_configs = [ ":public_include_path" ]
146   public = [ "public/pw_kvs/flash_test_partition.h" ]
147   sources = [ "fake_flash_test_partition.cc" ]
148   public_deps = [ ":flash_test_partition" ]
149   deps = [
150     ":fake_flash",
151     dir_pw_kvs,
152   ]
153   defines = [ "PW_FLASH_TEST_ALIGNMENT=64" ]
154 }
155
156 pw_source_set("fake_flash_256_aligned_partition") {
157   public_configs = [ ":public_include_path" ]
158   public = [ "public/pw_kvs/flash_test_partition.h" ]
159   sources = [ "fake_flash_test_partition.cc" ]
160   public_deps = [ ":flash_test_partition" ]
161   deps = [
162     ":fake_flash",
163     dir_pw_kvs,
164   ]
165   defines = [ "PW_FLASH_TEST_ALIGNMENT=256" ]
166 }
167
168 pw_source_set("fake_flash_test_key_value_store") {
169   public_configs = [ ":public_include_path" ]
170   sources = [ "fake_flash_test_key_value_store.cc" ]
171   public_deps = [ ":test_key_value_store" ]
172   deps = [
173     ":crc16",
174     ":fake_flash",
175     dir_pw_kvs,
176   ]
177 }
178
179 pw_source_set("flash_partition_test_100_iterations") {
180   deps = [
181     ":config",
182     ":flash_test_partition",
183     dir_pw_kvs,
184     dir_pw_log,
185     dir_pw_unit_test,
186   ]
187   sources = [ "flash_partition_test.cc" ]
188   defines = [ "PW_FLASH_TEST_ITERATIONS=100" ]
189 }
190
191 pw_source_set("flash_partition_test_2_iterations") {
192   deps = [
193     ":config",
194     ":flash_test_partition",
195     dir_pw_kvs,
196     dir_pw_log,
197     dir_pw_unit_test,
198   ]
199   sources = [ "flash_partition_test.cc" ]
200   defines = [ "PW_FLASH_TEST_ITERATIONS=2" ]
201 }
202
203 pw_source_set("key_value_store_initialized_test") {
204   deps = [
205     ":crc16",
206     ":flash_test_partition",
207     ":pw_kvs",
208     dir_pw_bytes,
209     dir_pw_checksum,
210     dir_pw_log,
211     dir_pw_unit_test,
212   ]
213   sources = [ "key_value_store_initialized_test.cc" ]
214 }
215
216 pw_source_set("test_key_value_store_test") {
217   deps = [
218     ":pw_kvs",
219     ":test_key_value_store",
220     dir_pw_unit_test,
221   ]
222   sources = [ "test_key_value_store_test.cc" ]
223 }
224
225 pw_source_set("test_partition") {
226   public_configs = [ ":public_include_path" ]
227   public = [ "public/pw_kvs/flash_partition_with_stats.h" ]
228   sources = [ "flash_partition_with_stats.cc" ]
229   visibility = [ ":*" ]
230   public_deps = [
231     dir_pw_kvs,
232     dir_pw_log,
233     dir_pw_status,
234   ]
235   deps = [ ":config" ]
236 }
237
238 pw_test_group("tests") {
239   tests = [
240     ":alignment_test",
241     ":checksum_test",
242     ":converts_to_span_test",
243     ":entry_test",
244     ":entry_cache_test",
245     ":flash_partition_small_test",
246     ":flash_partition_64_alignment_test",
247     ":flash_partition_256_alignment_test",
248     ":key_value_store_test",
249     ":key_value_store_small_flash_test",
250     ":key_value_store_64_alignment_flash_test",
251     ":key_value_store_256_alignment_flash_test",
252     ":key_value_store_binary_format_test",
253     ":key_value_store_fuzz_test",
254     ":key_value_store_map_test",
255     ":fake_flash_test_key_value_store_test",
256     ":sectors_test",
257     ":key_test",
258     ":key_value_store_wear_test",
259   ]
260 }
261
262 pw_test("alignment_test") {
263   deps = [ ":pw_kvs" ]
264   sources = [ "alignment_test.cc" ]
265 }
266
267 pw_test("checksum_test") {
268   deps = [
269     ":crc16",
270     ":pw_kvs",
271     dir_pw_log,
272   ]
273   sources = [ "checksum_test.cc" ]
274 }
275
276 pw_test("converts_to_span_test") {
277   deps = [ ":pw_kvs" ]
278   sources = [ "converts_to_span_test.cc" ]
279 }
280
281 pw_test("entry_test") {
282   deps = [
283     ":crc16",
284     ":fake_flash",
285     ":pw_kvs",
286     dir_pw_bytes,
287   ]
288   sources = [ "entry_test.cc" ]
289 }
290
291 pw_test("entry_cache_test") {
292   deps = [
293     ":fake_flash",
294     ":pw_kvs",
295     dir_pw_bytes,
296   ]
297   sources = [ "entry_cache_test.cc" ]
298 }
299
300 pw_test("flash_partition_small_test") {
301   deps = [
302     ":fake_flash",
303     ":fake_flash_small_partition",
304     ":flash_partition_test_100_iterations",
305     dir_pw_log,
306   ]
307 }
308
309 pw_test("flash_partition_64_alignment_test") {
310   deps = [
311     ":fake_flash",
312     ":fake_flash_64_aligned_partition",
313     ":flash_partition_test_100_iterations",
314     dir_pw_log,
315   ]
316 }
317
318 pw_test("flash_partition_256_alignment_test") {
319   deps = [
320     ":fake_flash",
321     ":fake_flash_256_aligned_partition",
322     ":flash_partition_test_100_iterations",
323     dir_pw_log,
324   ]
325 }
326
327 pw_test("key_value_store_test") {
328   deps = [
329     ":crc16",
330     ":fake_flash",
331     ":pw_kvs",
332     dir_pw_bytes,
333     dir_pw_checksum,
334     dir_pw_log,
335   ]
336   sources = [ "key_value_store_test.cc" ]
337 }
338
339 pw_test("key_value_store_small_flash_test") {
340   deps = [
341     ":fake_flash_small_partition",
342     ":key_value_store_initialized_test",
343   ]
344 }
345
346 pw_test("key_value_store_64_alignment_flash_test") {
347   deps = [
348     ":fake_flash_64_aligned_partition",
349     ":key_value_store_initialized_test",
350   ]
351 }
352
353 pw_test("key_value_store_256_alignment_flash_test") {
354   deps = [
355     ":fake_flash_256_aligned_partition",
356     ":key_value_store_initialized_test",
357   ]
358 }
359
360 pw_test("key_value_store_binary_format_test") {
361   deps = [
362     ":crc16",
363     ":fake_flash",
364     ":pw_kvs",
365     dir_pw_bytes,
366     dir_pw_log,
367   ]
368   sources = [ "key_value_store_binary_format_test.cc" ]
369 }
370
371 pw_test("key_value_store_fuzz_test") {
372   deps = [
373     ":crc16",
374     ":fake_flash",
375     ":pw_kvs",
376     ":test_partition",
377   ]
378   sources = [ "key_value_store_fuzz_test.cc" ]
379 }
380
381 pw_test("fake_flash_test_key_value_store_test") {
382   deps = [
383     ":fake_flash_test_key_value_store",
384     ":test_key_value_store_test",
385   ]
386 }
387
388 pw_test("key_value_store_map_test") {
389   deps = [
390     ":crc16",
391     ":fake_flash",
392     ":pw_kvs",
393     ":test_partition",
394     dir_pw_checksum,
395   ]
396   sources = [ "key_value_store_map_test.cc" ]
397 }
398
399 pw_test("sectors_test") {
400   deps = [
401     ":fake_flash",
402     ":pw_kvs",
403   ]
404   sources = [ "sectors_test.cc" ]
405 }
406
407 pw_test("key_test") {
408   deps = [ ":pw_kvs" ]
409   sources = [ "key_test.cc" ]
410 }
411
412 pw_test("key_value_store_wear_test") {
413   deps = [
414     ":fake_flash",
415     ":pw_kvs",
416     ":test_partition",
417     dir_pw_log,
418   ]
419   sources = [ "key_value_store_wear_test.cc" ]
420 }
421
422 pw_doc_group("docs") {
423   sources = [ "docs.rst" ]
424   report_deps = [ ":kvs_size" ]
425 }
426
427 pw_size_report("kvs_size") {
428   title = "Pigweed KVS size report"
429
430   # To see all the symbols, uncomment the following:
431   # Note: The size report RST table won't be generated when full_report = true.
432   # full_report = true
433
434   binaries = [
435     {
436       target = "size_report:with_kvs"
437       base = "size_report:base_with_only_flash"
438       label = "KeyValueStore"
439     },
440   ]
441
442   binaries += [
443     {
444       target = "size_report:base_with_only_flash"
445       base = "size_report:base"
446       label = "FlashPartition"
447     },
448   ]
449 }