1 # Copyright 2020 The Pigweed Authors
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
7 # https://www.apache.org/licenses/LICENSE-2.0
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
15 import("//build_overrides/pigweed.gni")
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")
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
30 config("public_include_path") {
31 include_dirs = [ "public" ]
35 pw_source_set("pw_kvs") {
36 public_configs = [ ":public_include_path" ]
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",
44 "public/pw_kvs/key.h",
45 "public/pw_kvs/key_value_store.h",
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",
78 pw_source_set("config") {
79 public_deps = [ pw_kvs_CONFIG ]
80 public = [ "pw_kvs_private/config.h" ]
84 pw_source_set("crc16") {
85 public = [ "public/pw_kvs/crc16_checksum.h" ]
92 pw_source_set("flash_test_partition") {
93 public = [ "public/pw_kvs/flash_test_partition.h" ]
94 public_deps = [ ":pw_kvs" ]
97 pw_source_set("test_key_value_store") {
98 public = [ "public/pw_kvs/test_key_value_store.h" ]
99 public_deps = [ ":pw_kvs" ]
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" ]
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" ]
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" ]
138 "PW_FLASH_TEST_SECTORS=3",
139 "PW_FLASH_TEST_SECTOR_SIZE=4",
140 "PW_FLASH_TEST_ALIGNMENT=4",
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" ]
153 defines = [ "PW_FLASH_TEST_ALIGNMENT=64" ]
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" ]
165 defines = [ "PW_FLASH_TEST_ALIGNMENT=256" ]
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" ]
179 pw_source_set("flash_partition_test_100_iterations") {
182 ":flash_test_partition",
187 sources = [ "flash_partition_test.cc" ]
188 defines = [ "PW_FLASH_TEST_ITERATIONS=100" ]
191 pw_source_set("flash_partition_test_2_iterations") {
194 ":flash_test_partition",
199 sources = [ "flash_partition_test.cc" ]
200 defines = [ "PW_FLASH_TEST_ITERATIONS=2" ]
203 pw_source_set("key_value_store_initialized_test") {
206 ":flash_test_partition",
213 sources = [ "key_value_store_initialized_test.cc" ]
216 pw_source_set("test_key_value_store_test") {
219 ":test_key_value_store",
222 sources = [ "test_key_value_store_test.cc" ]
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 = [ ":*" ]
238 pw_test_group("tests") {
242 ":converts_to_span_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",
258 ":key_value_store_wear_test",
262 pw_test("alignment_test") {
264 sources = [ "alignment_test.cc" ]
267 pw_test("checksum_test") {
273 sources = [ "checksum_test.cc" ]
276 pw_test("converts_to_span_test") {
278 sources = [ "converts_to_span_test.cc" ]
281 pw_test("entry_test") {
288 sources = [ "entry_test.cc" ]
291 pw_test("entry_cache_test") {
297 sources = [ "entry_cache_test.cc" ]
300 pw_test("flash_partition_small_test") {
303 ":fake_flash_small_partition",
304 ":flash_partition_test_100_iterations",
309 pw_test("flash_partition_64_alignment_test") {
312 ":fake_flash_64_aligned_partition",
313 ":flash_partition_test_100_iterations",
318 pw_test("flash_partition_256_alignment_test") {
321 ":fake_flash_256_aligned_partition",
322 ":flash_partition_test_100_iterations",
327 pw_test("key_value_store_test") {
336 sources = [ "key_value_store_test.cc" ]
339 pw_test("key_value_store_small_flash_test") {
341 ":fake_flash_small_partition",
342 ":key_value_store_initialized_test",
346 pw_test("key_value_store_64_alignment_flash_test") {
348 ":fake_flash_64_aligned_partition",
349 ":key_value_store_initialized_test",
353 pw_test("key_value_store_256_alignment_flash_test") {
355 ":fake_flash_256_aligned_partition",
356 ":key_value_store_initialized_test",
360 pw_test("key_value_store_binary_format_test") {
368 sources = [ "key_value_store_binary_format_test.cc" ]
371 pw_test("key_value_store_fuzz_test") {
378 sources = [ "key_value_store_fuzz_test.cc" ]
381 pw_test("fake_flash_test_key_value_store_test") {
383 ":fake_flash_test_key_value_store",
384 ":test_key_value_store_test",
388 pw_test("key_value_store_map_test") {
396 sources = [ "key_value_store_map_test.cc" ]
399 pw_test("sectors_test") {
404 sources = [ "sectors_test.cc" ]
407 pw_test("key_test") {
409 sources = [ "key_test.cc" ]
412 pw_test("key_value_store_wear_test") {
419 sources = [ "key_value_store_wear_test.cc" ]
422 pw_doc_group("docs") {
423 sources = [ "docs.rst" ]
424 report_deps = [ ":kvs_size" ]
427 pw_size_report("kvs_size") {
428 title = "Pigweed KVS size report"
430 # To see all the symbols, uncomment the following:
431 # Note: The size report RST table won't be generated when full_report = true.
436 target = "size_report:with_kvs"
437 base = "size_report:base_with_only_flash"
438 label = "KeyValueStore"
444 target = "size_report:base_with_only_flash"
445 base = "size_report:base"
446 label = "FlashPartition"