blob: 4083387105d2f28226eaf5a334446476843b0b22 [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 Hepler4da1fcb2020-01-30 17:32:18 -080031 "flash_memory.cc",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080032 "key_value_store.cc",
Wyatt Heplerbdd8e5a2020-02-20 19:27:26 -080033 "public/pw_kvs/internal/entry.h",
Wyatt Hepler1fc11042020-02-19 17:17:51 -080034 "public/pw_kvs/internal/hash.h",
35 "public/pw_kvs/internal/key_descriptor.h",
Wyatt Hepler2c7eca02020-02-18 16:01:42 -080036 "public/pw_kvs/internal/sector_descriptor.h",
Keir Mierle0dd24a82020-02-21 16:08:59 -080037 "public/pw_kvs/internal/span_traits.h",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080038 "pw_kvs_private/macros.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080039 ],
40 hdrs = [
Wyatt Hepler1927c282020-02-11 16:45:02 -080041 "public/pw_kvs/alignment.h",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080042 "public/pw_kvs/checksum.h",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080043 "public/pw_kvs/crc16_checksum.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080044 "public/pw_kvs/flash_memory.h",
Wyatt Hepler88adfe82020-02-20 19:33:27 -080045 "public/pw_kvs/format.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080046 "public/pw_kvs/key_value_store.h",
Wyatt Hepler1927c282020-02-11 16:45:02 -080047 "public/pw_kvs/output.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080048 ],
49 includes = ["public"],
50 deps = [
51 "//pw_checksum",
Wyatt Hepler1c329ca2020-02-07 18:07:23 -080052 "//pw_containers",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080053 "//pw_log",
54 "//pw_status",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080055 ],
56)
57
Wyatt Heplerec4b9352020-01-31 15:51:50 -080058pw_cc_library(
59 name = "crc16",
60 hdrs = [
61 "public/pw_kvs/crc16_checksum.h",
62 ],
63 deps = [
64 ":pw_kvs",
65 "//pw_checksum",
66 ],
67)
68
Wyatt Heplerad684a12020-02-04 17:17:29 -080069pw_cc_library(
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080070 name = "test_utils",
71 srcs = [
72 "in_memory_fake_flash.cc",
73 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080074 hdrs = [
75 "public/pw_kvs/in_memory_fake_flash.h",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080076 "pw_kvs_private/byte_utils.h",
Wyatt Heplerad684a12020-02-04 17:17:29 -080077 ],
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080078 includes = ["public"],
Wyatt Heplerad684a12020-02-04 17:17:29 -080079 visibility = ["//visibility:private"],
80 deps = [
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080081 "//pw_kvs",
Wyatt Heplerad684a12020-02-04 17:17:29 -080082 "//pw_log",
83 "//pw_status",
84 ],
85)
86
Wyatt Heplerec4b9352020-01-31 15:51:50 -080087pw_cc_test(
Wyatt Hepler1927c282020-02-11 16:45:02 -080088 name = "alignment_test",
89 srcs = [
90 "alignment_test.cc",
91 ],
92 deps = [
93 ":pw_kvs",
94 ],
95)
96
97pw_cc_test(
Wyatt Heplerec4b9352020-01-31 15:51:50 -080098 name = "checksum_test",
99 srcs = ["checksum_test.cc"],
100 deps = [
101 ":crc16",
102 ":pw_kvs",
103 "//pw_checksum",
104 "//pw_log",
105 ],
106)
107
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800108pw_cc_test(
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800109 name = "entry_test",
110 srcs = [
111 "entry_test.cc",
112 ],
113 deps = [
114 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800115 ":test_utils",
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800116 ],
117)
118
119pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800120 name = "key_value_store_test",
121 srcs = ["key_value_store_test.cc"],
122 deps = [
123 ":crc16",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800124 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800125 ":test_utils",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800126 "//pw_log",
127 ],
128)
129
130pw_cc_test(
131 name = "key_value_store_error_handling_test",
132 srcs = [
133 "key_value_store_error_handling_test.cc",
134 ],
135 deps = [
136 ":crc16",
137 ":pw_kvs",
138 ":test_utils",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800139 "//pw_log",
140 ],
141)
142
143pw_cc_test(
Wyatt Hepler16b04522020-02-07 16:00:14 -0800144 name = "key_value_store_fuzz_test",
145 srcs = ["key_value_store_fuzz_test.cc"],
146 deps = [
147 ":crc16",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800148 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800149 ":test_utils",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800150 "//pw_checksum",
151 ],
152)
153
154pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800155 name = "key_value_store_map_test",
156 srcs = ["key_value_store_map_test.cc"],
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800157 deps = [
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800158 ":crc16",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800159 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800160 ":test_utils",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800161 "//pw_checksum",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800162 ],
163)
Wyatt Heplerd6216822020-02-04 16:39:15 -0800164
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800165# TODO: This binary is not building due to a linker error. The error does not occur in GN Builds.
166# A filegroup is used below so that the file is included in the Bazel build.
167# cc_binary(
168# name = "debug_cli",
169# srcs = ["debug_cli.cc"],
170# copts = ["-std=c++17"],
171# deps = [
172# ":crc16",
173# ":pw_kvs",
174# ":test_utils",
175# ],
176# )
177
178filegroup(
Wyatt Heplerd6216822020-02-04 16:39:15 -0800179 name = "debug_cli",
180 srcs = ["debug_cli.cc"],
Wyatt Heplerd6216822020-02-04 16:39:15 -0800181)