• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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("@rules_proto//proto:defs.bzl", "proto_library")
16load("@rules_python//python:proto.bzl", "py_proto_library")
17load(
18    "//pw_build:pigweed.bzl",
19    "pw_cc_test",
20)
21load("//pw_protobuf_compiler:pw_proto_library.bzl", "pw_proto_library")
22
23package(default_visibility = ["//visibility:public"])
24
25licenses(["notice"])
26
27proto_library(
28    name = "tuf_proto",
29    srcs = [
30        "tuf.proto",
31    ],
32    deps = [
33        "@com_google_protobuf//:timestamp_proto",
34    ],
35)
36
37proto_library(
38    name = "update_bundle_proto",
39    srcs = [
40        "update_bundle.proto",
41    ],
42    deps = [
43        ":tuf_proto",
44    ],
45)
46
47pw_proto_library(
48    name = "update_bundle_proto_cc",
49    deps = [":update_bundle_proto"],
50)
51
52py_proto_library(
53    name = "update_bundle_py_pb2",
54    deps = [":update_bundle_proto"],
55)
56
57java_lite_proto_library(
58    name = "update_bundle_java_proto_lite",
59    deps = [":update_bundle_proto"],
60)
61
62proto_library(
63    name = "bundled_update_proto",
64    srcs = [
65        "bundled_update.proto",
66    ],
67    deps = [
68        "//pw_protobuf:common_proto",
69        "//pw_tokenizer:tokenizer_proto",
70        "@com_google_protobuf//:any_proto",
71    ],
72)
73
74py_proto_library(
75    name = "bundled_update_py_pb2",
76    deps = [":bundled_update_proto"],
77)
78
79java_lite_proto_library(
80    name = "bundled_update_java_proto_lite",
81    deps = [":bundled_update_proto"],
82)
83
84# TODO: b/258074401 - Depends on the `any` proto, which doesn't build under
85# nanopb.
86# pw_proto_library(
87#     name = "bundled_update_proto_cc",
88#     # TODO: b/258074760 - Adding this tag breaks the pw_proto_library rule.
89#     tags = ["manual"],
90#     deps = [":bundled_update_proto"],
91# )
92
93cc_library(
94    name = "openable_reader",
95    hdrs = [
96        "public/pw_software_update/openable_reader.h",
97    ],
98    deps = [
99        "//pw_stream",
100    ],
101)
102
103cc_library(
104    name = "blob_store_openable_reader",
105    hdrs = [
106        "public/pw_software_update/blob_store_openable_reader.h",
107    ],
108    deps = [
109        ":openable_reader",
110    ],
111)
112
113cc_library(
114    name = "update_bundle",
115    srcs = [
116        "manifest_accessor.cc",
117        "update_bundle_accessor.cc",
118    ],
119    hdrs = [
120        "public/pw_software_update/bundled_update_backend.h",
121        "public/pw_software_update/config.h",
122        "public/pw_software_update/manifest_accessor.h",
123        "public/pw_software_update/update_bundle_accessor.h",
124    ],
125    includes = ["public"],
126    tags = ["manual"],  # TODO: b/236321905 - Depends on pw_crypto.
127    deps = [
128        ":blob_store_openable_reader",
129        ":config_override",
130        ":openable_reader",
131        ":update_bundle_proto_cc.pwpb",
132        "//pw_blob_store",
133        "//pw_crypto:ecdsa_facade",
134        "//pw_crypto:sha256_facade",
135        "//pw_kvs",
136        "//pw_log",
137        "//pw_protobuf",
138        "//pw_status",
139        "//pw_stream",
140        "//pw_string",
141    ],
142)
143
144label_flag(
145    name = "config_override",
146    build_setting_default = "//pw_build:default_module_config",
147)
148
149# TODO: b/258074401 - Depends on bundled_update_proto_cc.nanopb_rpc, which
150# doesn't build yet.
151cc_library(
152    name = "bundled_update_service",
153    srcs = ["bundled_update_service.cc"],
154    hdrs = ["public/pw_software_update/bundled_update_service.h"],
155    includes = ["public"],
156    tags = ["manual"],
157    deps = [
158        # ":bundled_update_proto_cc.nanopb_rpc",
159        # ":bundled_update_proto_cc.pwpb",
160        ":update_bundle",
161        # ":update_bundle_proto_cc.nanopb_rpc",
162        # ":update_bundle_proto_cc.pwpb",
163        "//pw_log",
164        "//pw_result",
165        "//pw_status",
166        "//pw_sync:borrow",
167        "//pw_sync:lock_annotations",
168        "//pw_sync:mutex",
169        "//pw_tokenizer",
170        "//pw_work_queue",
171    ],
172)
173
174# TODO: b/258074401 - Depends on bundled_update_proto_cc.nanopb_rpc, which
175# doesn't build yet.
176cc_library(
177    name = "bundled_update_service_pwpb",
178    srcs = ["bundled_update_service_pwpb.cc"],
179    hdrs = ["public/pw_software_update/bundled_update_service_pwpb.h"],
180    includes = ["public"],
181    tags = ["manual"],
182    deps = [
183        # ":bundled_update_proto_cc.pwpb",
184        # ":bundled_update_proto_cc.pwpb_rpc",
185        ":update_bundle",
186        # ":update_bundle_proto_cc.pwpb",
187        # ":update_bundle_proto_cc.pwpb_rpc",
188        "//pw_log",
189        "//pw_result",
190        "//pw_status",
191        "//pw_string:util",
192        "//pw_sync:borrow",
193        "//pw_sync:lock_annotations",
194        "//pw_sync:mutex",
195        "//pw_tokenizer",
196        "//pw_work_queue",
197    ],
198)
199
200# TODO: b/258222107 - pw_python_action doesn't exist yet.
201# pw_python_action(
202#     name = "generate_test_bundle",
203#     outputs = ["$target_gen_dir/generate_test_bundle/test_bundles.h"],
204#     script = "py/pw_software_update/generate_test_bundle.py",
205#     deps = [
206#         ":bundled_update_py_pb2",
207#         "py",
208#     ],
209#     args = [ "$target_gen_dir/generate_test_bundle/test_bundles.h" ],
210# )
211
212pw_cc_test(
213    name = "update_bundle_test",
214    srcs = ["update_bundle_test.cc"],
215    tags = ["manual"],
216    deps = [
217        # This dependency is needed, but doesn't exist yet.
218        # "generate_test_bundle",
219        ":update_bundle",
220        "//pw_kvs:fake_flash_test_key_value_store",
221        "//pw_unit_test",
222    ],
223)
224
225pw_cc_test(
226    name = "bundled_update_service_test",
227    srcs = ["bundled_update_service_test.cc"],
228    tags = ["manual"],  # bundled_update_service doesn't work yet.
229    deps = [
230        ":bundled_update_service",
231        "//pw_unit_test",
232    ],
233)
234
235pw_cc_test(
236    name = "bundled_update_service_pwpb_test",
237    srcs = ["bundled_update_service_pwpb_test.cc"],
238    tags = ["manual"],  # bundled_update_service_pwpb doesn't work yet.
239    deps = [
240        ":bundled_update_service_pwpb",
241        "//pw_unit_test",
242    ],
243)
244