blob: 0e297f195e6e94dbf473fcae7ecf02985dec70b8 [file] [log] [blame]
# 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/assembly/bootfs_files_for_assembly.gni")
import("//build/components.gni")
import("//build/dist/component_manifest_resources.gni")
import("//build/rust/rustc_binary.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_test.gni")
import("//build/testing/environments.gni")
import("//build/toolchain/concurrent_jobs.gni")
import("//src/storage/fshost/generated_fshost_config.gni")
import("//src/sys/pkg/bin/grand-swd-binary/gsb.gni")
rustc_binary("bin") {
name = "pkg_cache"
with_unit_tests = true
edition = "2024"
deps = [
":config_lib",
"//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_rust",
"//sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_rust",
"//sdk/fidl/fuchsia.io:fuchsia.io_rust",
"//sdk/fidl/fuchsia.mem:fuchsia.mem_rust",
"//sdk/fidl/fuchsia.metrics:fuchsia.metrics_rust",
"//sdk/fidl/fuchsia.pkg:fuchsia.pkg_rust",
"//sdk/fidl/fuchsia.pkg.garbagecollector:fuchsia.pkg.garbagecollector_rust",
"//sdk/fidl/fuchsia.update:fuchsia.update_rust",
"//sdk/rust/zx",
"//src/lib/async-utils",
"//src/lib/cobalt/rust/builders",
"//src/lib/diagnostics/inspect/runtime/rust",
"//src/lib/diagnostics/inspect/rust",
"//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-runtime",
"//src/lib/fuchsia-sync",
"//src/lib/fuchsia-url",
"//src/lib/trace/rust:trace",
"//src/lib/trace/rust:trace-provider",
"//src/lib/versioning/version-history/rust",
"//src/storage/fxfs/fidl/fuchsia.fxfs:fuchsia.fxfs_rust",
"//src/storage/lib/vfs/rust:vfs",
"//src/sys/lib/fidl-fuchsia-component-abi-ext",
"//src/sys/lib/fidl-fuchsia-pkg-ext",
"//src/sys/lib/mem_util",
"//src/sys/pkg/lib/blobfs",
"//src/sys/pkg/lib/fuchsia-hash",
"//src/sys/pkg/lib/fuchsia-merkle",
"//src/sys/pkg/lib/metrics:cobalt_sw_delivery_registry_rustlib",
"//src/sys/pkg/lib/package-directory",
"//src/sys/pkg/lib/system-image",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:async-lock",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:hmac",
"//third_party/rust_crates:log",
"//third_party/rust_crates:rand",
"//third_party/rust_crates:sha2",
"//third_party/rust_crates:thiserror",
]
test_deps = [
"//src/lib/diagnostics/testing/diagnostics-assertions/rust:diagnostics-assertions",
"//src/storage/fxfs/fidl/fuchsia.fxfs:fuchsia.fxfs_rust",
"//src/sys/pkg/lib/far/rust:fuchsia-archive",
"//src/sys/pkg/lib/fuchsia-pkg",
"//src/sys/pkg/lib/fuchsia-pkg-testing",
"//src/sys/pkg/testing/blobfs-ramdisk",
"//third_party/rust_crates:assert_matches",
"//third_party/rust_crates:maplit",
"//third_party/rust_crates:tempfile",
"//third_party/rust_crates:test-case",
]
source_root = "src/main.rs"
sources = [
"src/base_packages.rs",
"src/base_resolver.rs",
"src/base_resolver/component.rs",
"src/base_resolver/context_authenticator.rs",
"src/base_resolver/package.rs",
"src/cache_service.rs",
"src/cache_service/missing_blobs.rs",
"src/compat.rs",
"src/compat/pkgfs.rs",
"src/compat/pkgfs/validation.rs",
"src/gc_service.rs",
"src/index.rs",
"src/index/package.rs",
"src/index/retained.rs",
"src/index/writing.rs",
"src/main.rs",
"src/required_blobs.rs",
"src/retained_packages_service.rs",
"src/root_dir.rs",
"src/test_utils.rs",
"src/upgradable_packages.rs",
]
visibility = [
":*",
"//src/sys/pkg/bin/grand-swd-binary:*",
]
configs += [
"//build/config/rust/lints:clippy_warn_all",
"//build/config/rust:bootfs",
]
# As this is a large binary that uses many resources to compile (and takes minutes when LTO is
# enabled, shift it to the large RBE worker pool)
_concurrent_jobs = concurrent_jobs.link_highmem
configs += _concurrent_jobs.configs
forward_variables_from(_concurrent_jobs.vars, "*")
}
fuchsia_component_manifest("manifest") {
component_name = "pkg-cache"
manifest = "meta/pkg-cache.cml"
}
fuchsia_structured_config_rust_lib("config_lib") {
cm_label = ":manifest"
name = "pkg_cache_config"
visibility = [ ":*" ]
}
fuchsia_structured_config_values2("config_values_from_gn") {
cm_label = ":manifest"
output_component_name = "pkg-cache-config"
values = {
# TODO(https://fxbug.dev/331302451) Populate this correctly.
all_packages_executable = false
use_system_image = true
enable_upgradable_packages = false
}
visibility = [ ":*" ]
}
fuchsia_structured_config_values2("config_values_from_gn-ignore-system-image") {
cm_label = ":manifest"
output_component_name = "pkg-cache-config"
values = {
# TODO(https://fxbug.dev/331302451) Populate this correctly.
all_packages_executable = false
use_system_image = false
enable_upgradable_packages = false
}
visibility = [ ":*" ]
}
fuchsia_structured_config_values2("config_values_from_gn-cpp-blobfs") {
cm_label = ":manifest"
output_component_name = "pkg-cache-config"
values = {
# TODO(https://fxbug.dev/331302451) Populate this correctly.
all_packages_executable = false
use_system_image = true
enable_upgradable_packages = false
}
visibility = [ ":*" ]
}
fuchsia_structured_config_values2("config_values_from_gn-fxblob") {
cm_label = ":manifest"
output_component_name = "pkg-cache-config"
values = {
# TODO(https://fxbug.dev/331302451) Populate this correctly.
all_packages_executable = false
use_system_image = true
enable_upgradable_packages = false
}
visibility = [ ":*" ]
}
fuchsia_component("component") {
cm_label = ":manifest"
deps = [ ":bin" ]
}
group("production-component-and-config") {
testonly = true
public_deps = [
":component",
":config_values_from_gn",
]
}
group("ignore-system-image-component-and-config") {
public_deps = [
":component",
":config_values_from_gn-ignore-system-image",
]
}
group("production-component-and-config-cpp-blobfs") {
testonly = true
public_deps = [
":component",
":config_values_from_gn-cpp-blobfs",
]
}
group("production-component-and-config-fxblob") {
testonly = true
public_deps = [
":component",
":config_values_from_gn-fxblob",
]
}
fuchsia_package("pkg-cache") {
deps = [ ":component" ]
}
fuchsia_component("pkg-cache-test") {
testonly = true
manifest = "meta/pkg-cache-bin-test.cml"
deps = [ ":bin_test" ]
}
fuchsia_test_package("pkg-cache-tests") {
test_specs = {
log_settings = {
max_severity = "ERROR"
}
}
test_components = [ ":pkg-cache-test" ]
deps = [ "//src/storage/testing:storage_driver_test_realm" ]
}
group("hermetic_tests") {
testonly = true
public_deps = [ ":pkg-cache-tests" ]
}
# If the file in this resource is included in the system_image package, then pkg-cache will *not*
# enforce executability restrictions.
resource("disable-executability-restrictions-resource") {
sources = [ "disable_executability_restrictions" ]
outputs = [ "data/pkgfs_disable_executability_restrictions" ]
visibility = [ ":*" ]
}
fuchsia_system_package("disable-executability-restrictions") {
deps = [
":disable-executability-restrictions-resource",
"//build/validate:non_production_tag",
]
visibility = [
"//bundles/assembly:*",
"//src/sys/pkg:*",
]
}