blob: 15899ad2d46d46d902822ed1f4e7164b06161c20 [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 Hepler2454f2d2020-03-20 12:54:35 -070039 "public/pw_kvs/internal/sectors.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 Heplerc84393f2020-03-20 11:23:24 -070042 "sectors.cc",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080043 ],
44 hdrs = [
Wyatt Hepler1927c282020-02-11 16:45:02 -080045 "public/pw_kvs/alignment.h",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080046 "public/pw_kvs/checksum.h",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080047 "public/pw_kvs/crc16_checksum.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080048 "public/pw_kvs/flash_memory.h",
Wyatt Hepler88adfe82020-02-20 19:33:27 -080049 "public/pw_kvs/format.h",
Wyatt Hepler06b1b0b2020-03-09 08:26:34 -070050 "public/pw_kvs/io.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080051 "public/pw_kvs/key_value_store.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080052 ],
53 includes = ["public"],
54 deps = [
David Rogersc0104462020-05-08 15:50:23 -070055 "//pw_assert",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080056 "//pw_checksum",
Wyatt Hepler1c329ca2020-02-07 18:07:23 -080057 "//pw_containers",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080058 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -070059 "//pw_log:facade",
60 "//pw_span",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080061 "//pw_status",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080062 ],
63)
64
Wyatt Heplerec4b9352020-01-31 15:51:50 -080065pw_cc_library(
66 name = "crc16",
67 hdrs = [
68 "public/pw_kvs/crc16_checksum.h",
69 ],
70 deps = [
71 ":pw_kvs",
72 "//pw_checksum",
Rob Mohr06819482020-04-06 13:25:43 -070073 "//pw_span",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080074 ],
75)
76
Wyatt Heplerad684a12020-02-04 17:17:29 -080077pw_cc_library(
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080078 name = "test_utils",
79 srcs = [
80 "in_memory_fake_flash.cc",
81 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080082 hdrs = [
83 "public/pw_kvs/in_memory_fake_flash.h",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080084 "pw_kvs_private/byte_utils.h",
Wyatt Heplerad684a12020-02-04 17:17:29 -080085 ],
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080086 includes = ["public"],
Wyatt Heplerad684a12020-02-04 17:17:29 -080087 visibility = ["//visibility:private"],
88 deps = [
Rob Mohr06819482020-04-06 13:25:43 -070089 "//pw_containers",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080090 "//pw_kvs",
Wyatt Heplerad684a12020-02-04 17:17:29 -080091 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -070092 "//pw_log:facade",
93 "//pw_span",
Wyatt Heplerad684a12020-02-04 17:17:29 -080094 "//pw_status",
95 ],
96)
97
David Rogers5cc5ce82020-03-13 19:19:03 -070098pw_cc_library(
99 name = "test_partition",
100 srcs = [
101 "flash_partition_with_stats.cc",
102 ],
103 hdrs = [
104 "public/pw_kvs/flash_partition_with_stats.h",
105 ],
106 includes = ["public"],
107 visibility = ["//visibility:private"],
108 deps = [
Rob Mohr06819482020-04-06 13:25:43 -0700109 "//pw_containers",
David Rogers5cc5ce82020-03-13 19:19:03 -0700110 "//pw_kvs",
111 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -0700112 "//pw_log:facade",
David Rogers5cc5ce82020-03-13 19:19:03 -0700113 "//pw_status",
114 ],
115)
116
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800117pw_cc_test(
Wyatt Hepler1927c282020-02-11 16:45:02 -0800118 name = "alignment_test",
119 srcs = [
120 "alignment_test.cc",
121 ],
122 deps = [
123 ":pw_kvs",
Rob Mohr06819482020-04-06 13:25:43 -0700124 "//pw_status",
125 "//pw_unit_test",
Wyatt Hepler1927c282020-02-11 16:45:02 -0800126 ],
127)
128
129pw_cc_test(
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800130 name = "checksum_test",
131 srcs = ["checksum_test.cc"],
132 deps = [
133 ":crc16",
134 ":pw_kvs",
135 "//pw_checksum",
136 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -0700137 "//pw_unit_test",
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800138 ],
139)
140
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800141pw_cc_test(
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800142 name = "entry_test",
143 srcs = [
144 "entry_test.cc",
145 ],
146 deps = [
147 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800148 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700149 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700150 "//pw_span",
151 "//pw_unit_test",
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800152 ],
153)
154
155pw_cc_test(
Wyatt Hepler7ded6da2020-03-11 18:24:43 -0700156 name = "entry_cache_test",
157 srcs = ["entry_cache_test.cc"],
Wyatt Hepler02946272020-03-18 10:36:22 -0700158 deps = [
159 ":pw_kvs",
160 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700161 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700162 "//pw_unit_test",
Wyatt Hepler02946272020-03-18 10:36:22 -0700163 ],
Wyatt Hepler7ded6da2020-03-11 18:24:43 -0700164)
165
166pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800167 name = "key_value_store_test",
168 srcs = ["key_value_store_test.cc"],
169 deps = [
170 ":crc16",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800171 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800172 ":test_utils",
Rob Mohr06819482020-04-06 13:25:43 -0700173 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700174 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700175 "//pw_log:facade",
176 "//pw_span",
177 "//pw_status",
178 "//pw_string",
179 "//pw_unit_test",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800180 ],
181)
182
183pw_cc_test(
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800184 name = "key_value_store_binary_format_test",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800185 srcs = [
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800186 "key_value_store_binary_format_test.cc",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800187 ],
188 deps = [
189 ":crc16",
190 ":pw_kvs",
191 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700192 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700193 "//pw_unit_test",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800194 ],
195)
196
197pw_cc_test(
Wyatt Hepler16b04522020-02-07 16:00:14 -0800198 name = "key_value_store_fuzz_test",
199 srcs = ["key_value_store_fuzz_test.cc"],
200 deps = [
201 ":crc16",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800202 ":pw_kvs",
David Rogers5cc5ce82020-03-13 19:19:03 -0700203 ":test_partition",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800204 ":test_utils",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800205 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700206 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700207 "//pw_unit_test",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800208 ],
209)
210
211pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800212 name = "key_value_store_map_test",
213 srcs = ["key_value_store_map_test.cc"],
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800214 deps = [
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800215 ":crc16",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800216 ":pw_kvs",
David Rogers5cc5ce82020-03-13 19:19:03 -0700217 ":test_partition",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800218 ":test_utils",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800219 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700220 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700221 "//pw_log:facade",
222 "//pw_span",
223 "//pw_unit_test",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800224 ],
225)
Wyatt Heplerd6216822020-02-04 16:39:15 -0800226
Wyatt Heplerc84393f2020-03-20 11:23:24 -0700227pw_cc_test(
228 name = "sectors_test",
229 srcs = ["sectors_test.cc"],
230 deps = [
231 ":pw_kvs",
232 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700233 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700234 "//pw_unit_test",
Wyatt Heplerc84393f2020-03-20 11:23:24 -0700235 ],
236)
237
Armando Montanezf9e93e12020-04-22 07:44:14 -0700238pw_cc_test(
239 name = "key_value_store_wear_test",
240 srcs = [
241 "key_value_store_wear_test.cc",
242 ],
243 deps = [
244 ":pw_kvs",
David Rogersd5138f32020-04-28 15:18:56 -0700245 ":test_partition",
Armando Montanezf9e93e12020-04-22 07:44:14 -0700246 ":test_utils",
247 "//pw_log:backend",
248 "//pw_unit_test",
249 ],
250)
251
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800252# TODO: This binary is not building due to a linker error. The error does not occur in GN Builds.
253# A filegroup is used below so that the file is included in the Bazel build.
254# cc_binary(
255# name = "debug_cli",
256# srcs = ["debug_cli.cc"],
257# copts = ["-std=c++17"],
258# deps = [
259# ":crc16",
260# ":pw_kvs",
261# ":test_utils",
262# ],
263# )
264
265filegroup(
Wyatt Heplerd6216822020-02-04 16:39:15 -0800266 name = "debug_cli",
267 srcs = ["debug_cli.cc"],
Wyatt Heplerd6216822020-02-04 16:39:15 -0800268)