| # Copyright 2018 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/components.gni") |
| import("//build/images/args.gni") |
| import("//build/rust/rustc_library.gni") |
| import("//build/testing/environments.gni") |
| import("//src/sys/pkg/bin/grand-swd-binary/gsb.gni") |
| import("pkg_resolver_config.gni") |
| |
| # `pkg-resolver` is conceptually a binary, but it built as a lib here so it can be |
| # aggregated into //src/sys/pkg/bin/grand-swd-binary to save disk space. |
| rustc_library("lib") { |
| name = "pkg_resolver" |
| with_unit_tests = true |
| edition = "2021" |
| |
| deps = [ |
| ":config_lib", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust", |
| "//sdk/fidl/fuchsia.metrics:fuchsia.metrics_rust", |
| "//sdk/fidl/fuchsia.pkg:fuchsia.pkg_rust", |
| "//sdk/fidl/fuchsia.pkg.internal:fuchsia.pkg.internal_rust", |
| "//sdk/fidl/fuchsia.pkg.rewrite:fuchsia.pkg.rewrite_rust", |
| "//src/lib/cobalt/rust/builders", |
| "//src/lib/diagnostics/inspect/contrib/rust", |
| "//src/lib/diagnostics/inspect/runtime/rust", |
| "//src/lib/diagnostics/inspect/rust", |
| "//src/lib/fdio/rust:fdio", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fidl/rust/fidl-contrib", |
| "//src/lib/fuchsia", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/fuchsia-fs", |
| "//src/lib/fuchsia-hyper", |
| "//src/lib/fuchsia-sync", |
| "//src/lib/fuchsia-url", |
| "//src/lib/http-sse:http_sse", |
| "//src/lib/http-uri-ext", |
| "//src/lib/trace/rust:trace", |
| "//src/lib/trace/rust:trace-provider", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//src/storage/lib/delivery_blob", |
| "//src/sys/lib/fidl-fuchsia-pkg-ext", |
| "//src/sys/lib/fidl-fuchsia-pkg-rewrite-ext", |
| "//src/sys/lib/fuchsia_backoff", |
| "//src/sys/pkg/lib/async-generator", |
| "//src/sys/pkg/lib/eager-package-config", |
| "//src/sys/pkg/lib/fuchsia-pkg", |
| "//src/sys/pkg/lib/metrics:cobalt_sw_delivery_registry_rustlib", |
| "//src/sys/pkg/lib/system-image", |
| "//src/sys/pkg/lib/work-queue", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:async-lock", |
| "//third_party/rust_crates:async-trait", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:http", |
| "//third_party/rust_crates:hyper", |
| "//third_party/rust_crates:omaha_client", |
| "//third_party/rust_crates:p256", |
| "//third_party/rust_crates:rand", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:thiserror", |
| "//third_party/rust_crates:tracing", |
| "//third_party/rust_crates:tuf", |
| "//third_party/rust_crates:typed-builder", |
| ] |
| |
| test_deps = [ |
| "//src/lib/diagnostics/testing/diagnostics-assertions/rust:diagnostics-assertions", |
| "//src/sys/pkg/lib/fuchsia-pkg-testing", |
| "//third_party/cobalt/src/lib/client/rust:cobalt-client", |
| "//third_party/rust_crates:assert_matches", |
| "//third_party/rust_crates:derive_builder", |
| "//third_party/rust_crates:maplit", |
| "//third_party/rust_crates:p256", |
| "//third_party/rust_crates:tempfile", |
| ] |
| |
| source_root = "src/main.rs" |
| sources = [ |
| "src/cache.rs", |
| "src/cache/inspect.rs", |
| "src/cache/resume.rs", |
| "src/cache/retry.rs", |
| "src/cache_package_index.rs", |
| "src/clock.rs", |
| "src/config.rs", |
| "src/eager_package_manager.rs", |
| "src/error.rs", |
| "src/inspect_util.rs", |
| "src/main.rs", |
| "src/metrics_util.rs", |
| "src/repository.rs", |
| "src/repository/filesystem_repository.rs", |
| "src/repository/updating_tuf_client.rs", |
| "src/repository_manager.rs", |
| "src/repository_service.rs", |
| "src/resolver_service.rs", |
| "src/resolver_service/inspect.rs", |
| "src/resolver_service/resolve_with_context.rs", |
| "src/rewrite_manager.rs", |
| "src/rewrite_service.rs", |
| "src/test_util.rs", |
| "src/util.rs", |
| ] |
| |
| visibility = [ |
| ":*", |
| "//src/sys/pkg/bin/grand-swd-binary:*", |
| ] |
| configs += [ "//build/config/rust/lints:clippy_warn_all" ] |
| } |
| |
| grand_swd_binary("bin") { |
| output_name = "pkg_resolver" |
| } |
| |
| fuchsia_component_manifest("manifest") { |
| component_name = "pkg-resolver" |
| manifest = "meta/pkg-resolver.cml" |
| } |
| |
| fuchsia_component("component") { |
| cm_label = ":manifest" |
| deps = [ ":bin" ] |
| } |
| |
| group("production-component-and-config") { |
| public_deps = [ |
| ":component", |
| ":config_values_from_gn", |
| ] |
| } |
| |
| group("eng-component-and-config") { |
| public_deps = [ |
| ":component", |
| ":eng_config_values_from_gn", |
| ] |
| } |
| |
| fuchsia_package("pkg-resolver") { |
| deps = [ ":production-component-and-config" ] |
| } |
| |
| fuchsia_package("pkg-resolver-eng") { |
| package_name = "pkg-resolver" |
| deps = [ ":eng-component-and-config" ] |
| } |
| |
| fuchsia_test_component("unit-tests-root") { |
| component_name = "test_root" |
| manifest = "meta/test_root.cml" |
| |
| # Depends on root ssl certificate which is a system capability. |
| test_type = "system" |
| } |
| |
| fuchsia_component("unit-tests-driver") { |
| component_name = "test_driver" |
| testonly = true |
| manifest = "meta/test_driver.cml" |
| deps = [ ":lib_test" ] |
| } |
| |
| fuchsia_test_package("unit-tests-package") { |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| } |
| package_name = "pkg-resolver-tests" |
| deps = [ |
| ":unit-tests-driver", |
| "//src/connectivity/network:netstack-for-tests", |
| "//src/connectivity/network/dns:component", |
| "//src/sys/pkg/tests/pkg-resolver:empty-repo", |
| ] |
| test_components = [ ":unit-tests-root" ] |
| } |
| |
| pkg_resolver_config("enable_dynamic_configuration") { |
| enable_dynamic_configuration = true |
| deps = [ "//build/validate:non_production_tag" ] |
| } |
| |
| resolver_persisted_repos_config("persisted_repos_dir") { |
| persisted_repos_dir = "repos" |
| deps = [ "//build/validate:non_production_tag" ] |
| } |
| |
| fuchsia_structured_config_rust_lib("config_lib") { |
| cm_label = ":manifest" |
| name = "pkg_resolver_config" |
| visibility = [ ":*" ] |
| } |
| |
| # LINT.IfChange |
| structured_config_values = { |
| delivery_blob_type = delivery_blob_type |
| |
| # Repository size is currently 100 KB. Allowing for 10x growth and assuming a |
| # 4,096 B/s minimum bandwidth (the default minimum bandwidth used by rust-tuf |
| # HttpRepository) results in a duration of (10 * 100,000 B) / (4,096 B/s) = 244 seconds. |
| # Round to the minute boundary to make it more clear when reconstructing logs |
| # that there is a designed timeout involved. |
| # TODO(https://fxbug.dev/42140681) replace with granular timeouts in rust-tuf. |
| tuf_metadata_timeout_seconds = 240 |
| blob_network_header_timeout_seconds = 30 |
| blob_network_body_timeout_seconds = 30 |
| blob_download_resumption_attempts_limit = 50 |
| |
| # 2 reduces OTA time by 20-30% on fast networks. |
| # Not set higher to avoid OOM on the most memory constrained hardware. |
| blob_download_concurrency_limit = 2 |
| } |
| |
| # LINT.ThenChange(/src/sys/pkg/tests/pkg-resolver/BUILD.gn) |
| |
| fuchsia_structured_config_values("config_values_from_gn") { |
| cm_label = ":manifest" |
| |
| values = structured_config_values |
| } |
| |
| fuchsia_structured_config_values("eng_config_values_from_gn") { |
| cm_label = ":manifest" |
| |
| values = structured_config_values |
| } |
| |
| group("tests") { |
| testonly = true |
| public_deps = [ ":unit-tests-package" ] |
| } |