blob: 97000136f81681be077280e2a7c5b60d90f26e0c [file] [log] [blame]
Wyatt Hepler2ad60672020-01-21 08:00:16 -08001# 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
15load(
16 "//pw_build:pigweed.bzl",
17 "pw_cc_library",
18 "pw_cc_test",
19)
20
21package(default_visibility = ["//visibility:public"])
22
23licenses(["notice"]) # Apache License 2.0
24
25pw_cc_library(
26 name = "pw_kvs",
27 srcs = [
Wyatt Hepler1927c282020-02-11 16:45:02 -080028 "alignment.cc",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080029 "checksum.cc",
Wyatt Heplerd31d9702020-02-14 08:46:36 -080030 "entry.cc",
Wyatt Hepler7ded6da2020-03-11 18:24:43 -070031 "entry_cache.cc",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080032 "flash_memory.cc",
Wyatt Hepler22d0d9f2020-03-05 14:57:11 -080033 "format.cc",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080034 "key_value_store.cc",
Wyatt Heplerbdd8e5a2020-02-20 19:27:26 -080035 "public/pw_kvs/internal/entry.h",
Wyatt Hepler7ded6da2020-03-11 18:24:43 -070036 "public/pw_kvs/internal/entry_cache.h",
Wyatt Hepler1fc11042020-02-19 17:17:51 -080037 "public/pw_kvs/internal/hash.h",
38 "public/pw_kvs/internal/key_descriptor.h",
Wyatt Hepler2c7eca02020-02-18 16:01:42 -080039 "public/pw_kvs/internal/sector_descriptor.h",
Keir Mierle0dd24a82020-02-21 16:08:59 -080040 "public/pw_kvs/internal/span_traits.h",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080041 "pw_kvs_private/macros.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080042 ],
43 hdrs = [
Wyatt Hepler1927c282020-02-11 16:45:02 -080044 "public/pw_kvs/alignment.h",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080045 "public/pw_kvs/checksum.h",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080046 "public/pw_kvs/crc16_checksum.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080047 "public/pw_kvs/flash_memory.h",
Wyatt Hepler88adfe82020-02-20 19:33:27 -080048 "public/pw_kvs/format.h",
Wyatt Hepler06b1b0b2020-03-09 08:26:34 -070049 "public/pw_kvs/io.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080050 "public/pw_kvs/key_value_store.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080051 ],
52 includes = ["public"],
53 deps = [
54 "//pw_checksum",
Wyatt Hepler1c329ca2020-02-07 18:07:23 -080055 "//pw_containers",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080056 "//pw_log",
57 "//pw_status",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080058 ],
59)
60
Wyatt Heplerec4b9352020-01-31 15:51:50 -080061pw_cc_library(
62 name = "crc16",
63 hdrs = [
64 "public/pw_kvs/crc16_checksum.h",
65 ],
66 deps = [
67 ":pw_kvs",
68 "//pw_checksum",
69 ],
70)
71
Wyatt Heplerad684a12020-02-04 17:17:29 -080072pw_cc_library(
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080073 name = "test_utils",
74 srcs = [
75 "in_memory_fake_flash.cc",
76 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080077 hdrs = [
78 "public/pw_kvs/in_memory_fake_flash.h",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080079 "pw_kvs_private/byte_utils.h",
Wyatt Heplerad684a12020-02-04 17:17:29 -080080 ],
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080081 includes = ["public"],
Wyatt Heplerad684a12020-02-04 17:17:29 -080082 visibility = ["//visibility:private"],
83 deps = [
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080084 "//pw_kvs",
Wyatt Heplerad684a12020-02-04 17:17:29 -080085 "//pw_log",
86 "//pw_status",
87 ],
88)
89
Wyatt Heplerec4b9352020-01-31 15:51:50 -080090pw_cc_test(
Wyatt Hepler1927c282020-02-11 16:45:02 -080091 name = "alignment_test",
92 srcs = [
93 "alignment_test.cc",
94 ],
95 deps = [
96 ":pw_kvs",
97 ],
98)
99
100pw_cc_test(
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800101 name = "checksum_test",
102 srcs = ["checksum_test.cc"],
103 deps = [
104 ":crc16",
105 ":pw_kvs",
106 "//pw_checksum",
107 "//pw_log",
108 ],
109)
110
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800111pw_cc_test(
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800112 name = "entry_test",
113 srcs = [
114 "entry_test.cc",
115 ],
116 deps = [
117 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800118 ":test_utils",
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800119 ],
120)
121
122pw_cc_test(
Wyatt Hepler7ded6da2020-03-11 18:24:43 -0700123 name = "entry_cache_test",
124 srcs = ["entry_cache_test.cc"],
125 deps = [":pw_kvs"],
126)
127
128pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800129 name = "key_value_store_test",
130 srcs = ["key_value_store_test.cc"],
131 deps = [
132 ":crc16",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800133 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800134 ":test_utils",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800135 "//pw_log",
136 ],
137)
138
139pw_cc_test(
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800140 name = "key_value_store_binary_format_test",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800141 srcs = [
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800142 "key_value_store_binary_format_test.cc",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800143 ],
144 deps = [
145 ":crc16",
146 ":pw_kvs",
147 ":test_utils",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800148 "//pw_log",
149 ],
150)
151
152pw_cc_test(
Wyatt Hepler16b04522020-02-07 16:00:14 -0800153 name = "key_value_store_fuzz_test",
154 srcs = ["key_value_store_fuzz_test.cc"],
155 deps = [
156 ":crc16",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800157 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800158 ":test_utils",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800159 "//pw_checksum",
160 ],
161)
162
163pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800164 name = "key_value_store_map_test",
165 srcs = ["key_value_store_map_test.cc"],
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800166 deps = [
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800167 ":crc16",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800168 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800169 ":test_utils",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800170 "//pw_checksum",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800171 ],
172)
Wyatt Heplerd6216822020-02-04 16:39:15 -0800173
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800174# TODO: This binary is not building due to a linker error. The error does not occur in GN Builds.
175# A filegroup is used below so that the file is included in the Bazel build.
176# cc_binary(
177# name = "debug_cli",
178# srcs = ["debug_cli.cc"],
179# copts = ["-std=c++17"],
180# deps = [
181# ":crc16",
182# ":pw_kvs",
183# ":test_utils",
184# ],
185# )
186
187filegroup(
Wyatt Heplerd6216822020-02-04 16:39:15 -0800188 name = "debug_cli",
189 srcs = ["debug_cli.cc"],
Wyatt Heplerd6216822020-02-04 16:39:15 -0800190)