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