blob: 9c0197330786eaf68329cb4eb91625fbf4db2881 [file]
# Copyright 2021 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
load("@com_google_protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_protobuf_compiler:pw_proto_library.bzl", "nanopb_proto_library", "nanopb_rpc_proto_library", "pw_proto_filegroup", "pwpb_proto_library", "pwpb_rpc_proto_library")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
proto_library(
name = "tuf_proto",
srcs = [
"tuf.proto",
],
deps = [
"@com_google_protobuf//:timestamp_proto",
],
)
py_proto_library(
name = "tuf_py_pb2",
deps = [":tuf_proto"],
)
proto_library(
name = "update_bundle_proto",
srcs = [
"update_bundle.proto",
],
deps = [
":tuf_proto",
],
)
pwpb_proto_library(
name = "update_bundle_proto_pwpb",
deps = [":update_bundle_proto"],
)
py_proto_library(
name = "update_bundle_py_pb2",
deps = [":update_bundle_proto"],
)
java_lite_proto_library(
name = "update_bundle_java_proto_lite",
deps = [":update_bundle_proto"],
)
pw_proto_filegroup(
name = "bundled_update_filegroup",
srcs = ["bundled_update.proto"],
options_files = [
"bundled_update.options",
"bundled_update.pwpb_options",
],
)
proto_library(
name = "bundled_update_proto",
srcs = [":bundled_update_filegroup"],
deps = [
"//pw_protobuf:common_proto",
"//pw_tokenizer:tokenizer_proto",
"@com_google_protobuf//:any_proto",
],
)
pwpb_proto_library(
name = "bundled_update_proto_pwpb",
deps = [":bundled_update_proto"],
)
pwpb_rpc_proto_library(
name = "bundled_update_proto_pwpb_rpc",
pwpb_proto_library_deps = [":bundled_update_proto_pwpb"],
deps = [":bundled_update_proto"],
)
nanopb_proto_library(
name = "bundled_update_proto_nanopb",
deps = [":bundled_update_proto"],
)
nanopb_rpc_proto_library(
name = "bundled_update_proto_nanopb_rpc",
nanopb_proto_library_deps = [":bundled_update_proto_nanopb"],
deps = [":bundled_update_proto"],
)
py_proto_library(
name = "bundled_update_py_pb2",
deps = [":bundled_update_proto"],
)
java_lite_proto_library(
name = "bundled_update_java_proto_lite",
deps = [":bundled_update_proto"],
)
# TODO: b/258074401 - Depends on the `any` proto, which doesn't build under
# nanopb.
# pw_proto_library(
# name = "bundled_update_proto_cc",
# # TODO: b/258074760 - Adding this tag breaks the pw_proto_library rule.
# tags = ["manual"],
# deps = [":bundled_update_proto"],
# )
cc_library(
name = "openable_reader",
hdrs = [
"public/pw_software_update/openable_reader.h",
],
strip_include_prefix = "public",
deps = [
"//pw_stream",
],
)
cc_library(
name = "blob_store_openable_reader",
hdrs = [
"public/pw_software_update/blob_store_openable_reader.h",
],
features = ["-conversion_warnings"],
strip_include_prefix = "public",
deps = [
":openable_reader",
"//pw_blob_store",
],
)
cc_library(
name = "update_bundle",
srcs = [
"manifest_accessor.cc",
"update_bundle_accessor.cc",
],
hdrs = [
"public/pw_software_update/bundled_update_backend.h",
"public/pw_software_update/config.h",
"public/pw_software_update/manifest_accessor.h",
"public/pw_software_update/update_bundle_accessor.h",
],
strip_include_prefix = "public",
deps = [
":blob_store_openable_reader",
":config_override",
":openable_reader",
":update_bundle_proto_pwpb",
"//pw_blob_store",
"//pw_crypto:ecdsa",
"//pw_crypto:sha256",
"//pw_kvs",
"//pw_log",
"//pw_protobuf",
"//pw_result",
"//pw_status",
"//pw_stream",
"//pw_stream:interval_reader",
"//pw_string",
"//pw_string:builder",
],
)
label_flag(
name = "config_override",
build_setting_default = "//pw_build:default_module_config",
)
# TODO: b/258074401 - Depends on bundled_update_proto_cc.nanopb_rpc, which
# doesn't build yet.
cc_library(
name = "bundled_update_service",
srcs = ["bundled_update_service.cc"],
hdrs = ["public/pw_software_update/bundled_update_service.h"],
strip_include_prefix = "public",
deps = [
":bundled_update_proto_nanopb",
":bundled_update_proto_nanopb_rpc",
":update_bundle",
":update_bundle_proto_pwpb",
"//pw_log",
"//pw_result",
"//pw_status",
"//pw_string:builder",
"//pw_string:util",
"//pw_sync:borrow",
"//pw_sync:lock_annotations",
"//pw_sync:mutex",
"//pw_tokenizer",
"//pw_work_queue",
],
)
# TODO: b/258074401 - Depends on bundled_update_proto_cc.nanopb_rpc, which
# doesn't build yet.
cc_library(
name = "bundled_update_service_pwpb",
srcs = ["bundled_update_service_pwpb.cc"],
hdrs = ["public/pw_software_update/bundled_update_service_pwpb.h"],
strip_include_prefix = "public",
deps = [
":bundled_update_proto_pwpb",
":bundled_update_proto_pwpb_rpc",
":update_bundle",
":update_bundle_proto_pwpb",
"//pw_log",
"//pw_result",
"//pw_status",
"//pw_string:builder",
"//pw_string:util",
"//pw_sync:borrow",
"//pw_sync:lock_annotations",
"//pw_sync:mutex",
"//pw_tokenizer",
"//pw_work_queue",
],
)
genrule(
name = "generate_test_bundle",
outs = ["test_bundles.h"],
cmd = "$(execpath //pw_software_update/py:generate_test_bundle) $@",
tools = ["//pw_software_update/py:generate_test_bundle"],
)
pw_cc_test(
name = "update_bundle_test",
srcs = [
"update_bundle_test.cc",
":generate_test_bundle",
],
deps = [
":blob_store_openable_reader",
":update_bundle",
"//pw_blob_store",
"//pw_bytes",
"//pw_kvs:fake_flash",
"//pw_kvs:fake_flash_test_key_value_store",
"//pw_stream",
],
)
pw_cc_test(
name = "bundled_update_service_test",
srcs = ["bundled_update_service_test.cc"],
deps = [":bundled_update_service"],
)
pw_cc_test(
name = "bundled_update_service_pwpb_test",
srcs = ["bundled_update_service_pwpb_test.cc"],
deps = [":bundled_update_service_pwpb"],
)
sphinx_docs_library(
name = "docs",
srcs = [
"cli.rst",
"design.rst",
"docs.rst",
"get_started.rst",
"guides.rst",
],
prefix = "pw_software_update/",
target_compatible_with = incompatible_with_mcu(),
)