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