blob: 0bb21205b518e26396e8ee102739207118d2b311 [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",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080037 "pw_kvs_private/macros.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080038 ],
39 hdrs = [
Wyatt Hepler1927c282020-02-11 16:45:02 -080040 "public/pw_kvs/alignment.h",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080041 "public/pw_kvs/checksum.h",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080042 "public/pw_kvs/crc16_checksum.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080043 "public/pw_kvs/flash_memory.h",
Wyatt Hepler88adfe82020-02-20 19:33:27 -080044 "public/pw_kvs/format.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080045 "public/pw_kvs/key_value_store.h",
Wyatt Hepler1927c282020-02-11 16:45:02 -080046 "public/pw_kvs/output.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080047 ],
48 includes = ["public"],
49 deps = [
50 "//pw_checksum",
Wyatt Hepler1c329ca2020-02-07 18:07:23 -080051 "//pw_containers",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080052 "//pw_log",
53 "//pw_status",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080054 ],
55)
56
Wyatt Heplerec4b9352020-01-31 15:51:50 -080057pw_cc_library(
58 name = "crc16",
59 hdrs = [
60 "public/pw_kvs/crc16_checksum.h",
61 ],
62 deps = [
63 ":pw_kvs",
64 "//pw_checksum",
65 ],
66)
67
Wyatt Heplerad684a12020-02-04 17:17:29 -080068pw_cc_library(
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080069 name = "test_utils",
70 srcs = [
71 "in_memory_fake_flash.cc",
72 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080073 hdrs = [
74 "public/pw_kvs/in_memory_fake_flash.h",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080075 "pw_kvs_private/byte_utils.h",
Wyatt Heplerad684a12020-02-04 17:17:29 -080076 ],
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080077 includes = ["public"],
Wyatt Heplerad684a12020-02-04 17:17:29 -080078 visibility = ["//visibility:private"],
79 deps = [
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080080 "//pw_kvs",
Wyatt Heplerad684a12020-02-04 17:17:29 -080081 "//pw_log",
82 "//pw_status",
83 ],
84)
85
Wyatt Heplerec4b9352020-01-31 15:51:50 -080086pw_cc_test(
Wyatt Hepler1927c282020-02-11 16:45:02 -080087 name = "alignment_test",
88 srcs = [
89 "alignment_test.cc",
90 ],
91 deps = [
92 ":pw_kvs",
93 ],
94)
95
96pw_cc_test(
Wyatt Heplerec4b9352020-01-31 15:51:50 -080097 name = "checksum_test",
98 srcs = ["checksum_test.cc"],
99 deps = [
100 ":crc16",
101 ":pw_kvs",
102 "//pw_checksum",
103 "//pw_log",
104 ],
105)
106
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800107pw_cc_test(
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800108 name = "entry_test",
109 srcs = [
110 "entry_test.cc",
111 ],
112 deps = [
113 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800114 ":test_utils",
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800115 ],
116)
117
118pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800119 name = "key_value_store_test",
120 srcs = ["key_value_store_test.cc"],
121 deps = [
122 ":crc16",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800123 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800124 ":test_utils",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800125 "//pw_checksum",
126 "//pw_log",
127 ],
128)
129
130pw_cc_test(
Wyatt Hepler16b04522020-02-07 16:00:14 -0800131 name = "key_value_store_fuzz_test",
132 srcs = ["key_value_store_fuzz_test.cc"],
133 deps = [
134 ":crc16",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800135 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800136 ":test_utils",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800137 "//pw_checksum",
138 ],
139)
140
141pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800142 name = "key_value_store_map_test",
143 srcs = ["key_value_store_map_test.cc"],
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800144 deps = [
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800145 ":crc16",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800146 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800147 ":test_utils",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800148 "//pw_checksum",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800149 ],
150)
Wyatt Heplerd6216822020-02-04 16:39:15 -0800151
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800152# TODO: This binary is not building due to a linker error. The error does not occur in GN Builds.
153# A filegroup is used below so that the file is included in the Bazel build.
154# cc_binary(
155# name = "debug_cli",
156# srcs = ["debug_cli.cc"],
157# copts = ["-std=c++17"],
158# deps = [
159# ":crc16",
160# ":pw_kvs",
161# ":test_utils",
162# ],
163# )
164
165filegroup(
Wyatt Heplerd6216822020-02-04 16:39:15 -0800166 name = "debug_cli",
167 srcs = ["debug_cli.cc"],
Wyatt Heplerd6216822020-02-04 16:39:15 -0800168)