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