|  | # Copyright 2020 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/package.gni") | 
|  | import("//build/rust/rustc_library.gni") | 
|  | import("//build/test/test_package.gni") | 
|  | import("//build/testing/environments.gni") | 
|  |  | 
|  | rustc_library("isolated-swd") { | 
|  | version = "0.1.0" | 
|  | edition = "2018" | 
|  | with_unit_tests = true | 
|  |  | 
|  | deps = [ | 
|  | "//sdk/fidl/fuchsia.boot:fuchsia.boot-rustc", | 
|  | "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", | 
|  | "//sdk/fidl/fuchsia.logger:fuchsia.logger-rustc", | 
|  | "//sdk/fidl/fuchsia.net:fuchsia.net-rustc", | 
|  | "//sdk/fidl/fuchsia.paver:fuchsia.paver-rustc", | 
|  | "//sdk/fidl/fuchsia.pkg:fuchsia.pkg-rustc", | 
|  | "//sdk/fidl/fuchsia.posix.socket:fuchsia.posix.socket-rustc", | 
|  | "//sdk/fidl/fuchsia.tracing.provider:fuchsia.tracing.provider-rustc", | 
|  | "//src/lib/fdio/rust:fdio", | 
|  | "//src/lib/fidl/rust/fidl", | 
|  | "//src/lib/fuchsia-async", | 
|  | "//src/lib/fuchsia-component", | 
|  | "//src/lib/fuchsia-hyper", | 
|  | "//src/lib/fuchsia-runtime", | 
|  | "//src/lib/fuchsia-url", | 
|  | "//src/lib/scoped_task", | 
|  | "//src/lib/syslog/rust:syslog", | 
|  | "//src/lib/zircon/rust:fuchsia-zircon", | 
|  | "//src/sys/lib/fidl-fuchsia-pkg-ext", | 
|  | "//src/sys/pkg/fidl/fuchsia.update.installer:fuchsia.update.installer-rustc", | 
|  | "//src/sys/pkg/lib/fidl-fuchsia-update-installer-ext", | 
|  | "//src/sys/pkg/lib/fuchsia-merkle", | 
|  | "//src/sys/pkg/lib/fuchsia-pkg-testing", | 
|  | "//src/sys/pkg/lib/omaha-client", | 
|  | "//src/sys/pkg/lib/pkgfs", | 
|  | "//src/sys/pkg/lib/version", | 
|  | "//src/sys/pkg/testing/blobfs-ramdisk", | 
|  | "//src/sys/pkg/testing/mock-paver", | 
|  | "//third_party/rust_crates:anyhow", | 
|  | "//third_party/rust_crates:futures", | 
|  | "//third_party/rust_crates:hyper", | 
|  | "//third_party/rust_crates:hyper-rustls", | 
|  | "//third_party/rust_crates:log", | 
|  | "//third_party/rust_crates:matches", | 
|  | "//third_party/rust_crates:serde_json", | 
|  | "//third_party/rust_crates:tempfile", | 
|  | "//third_party/rust_crates:thiserror", | 
|  | ] | 
|  |  | 
|  | test_deps = [ | 
|  | "//sdk/fidl/fuchsia.sys:fuchsia.sys-rustc", | 
|  | "//third_party/rust_crates:hyper", | 
|  | "//third_party/rust_crates:openat", | 
|  | ] | 
|  |  | 
|  | sources = [ | 
|  | "src/cache.rs", | 
|  | "src/lib.rs", | 
|  | "src/omaha.rs", | 
|  | "src/omaha/http_request.rs", | 
|  | "src/omaha/install_plan.rs", | 
|  | "src/omaha/installer.rs", | 
|  | "src/omaha/timer.rs", | 
|  | "src/pkgfs.rs", | 
|  | "src/resolver.rs", | 
|  | "src/updater.rs", | 
|  | ] | 
|  | } | 
|  |  | 
|  | generate_manifest("empty-repo.manifest") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  | sources = [] | 
|  | args = [] | 
|  |  | 
|  | foreach(path, | 
|  | [ | 
|  | "keys/root.json", | 
|  | "keys/snapshot.json", | 
|  | "keys/targets.json", | 
|  | "keys/timestamp.json", | 
|  | "repository/1.root.json", | 
|  | "repository/1.snapshot.json", | 
|  | "repository/1.targets.json", | 
|  | "repository/root.json", | 
|  | "repository/snapshot.json", | 
|  | "repository/targets.json", | 
|  | "repository/timestamp.json", | 
|  | ]) { | 
|  | source = "//src/sys/pkg/tests/pkg-resolver/template/${path}" | 
|  | sources += [ source ] | 
|  | args += [ "--entry=empty-repo/${path}=" + rebase_path(source) ] | 
|  | } | 
|  | } | 
|  |  | 
|  | empty_repo_manifest_outputs = get_target_outputs(":empty-repo.manifest") | 
|  | empty_repo_manifest = empty_repo_manifest_outputs[0] | 
|  |  | 
|  | test_package("isolated-swd-tests") { | 
|  | extra = [ empty_repo_manifest ] | 
|  | deps = [ | 
|  | ":empty-repo.manifest", | 
|  | ":isolated-swd_test", | 
|  | "//garnet/go/src/grand_unified_binary", | 
|  | "//src/storage/bin/blobfs", | 
|  | "//src/sys/pkg/bin/grand-swd-binary", | 
|  | "//src/sys/pkg/bin/pkg-cache:bin", | 
|  | "//src/sys/pkg/bin/system-updater:bin", | 
|  | ] | 
|  |  | 
|  | binaries = [ | 
|  | { | 
|  | name = "blobfs" | 
|  | }, | 
|  | { | 
|  | name = "pkg-cache" | 
|  | source = "pkg_cache" | 
|  | }, | 
|  | { | 
|  | name = "pkg-resolver" | 
|  | source = "grand_swd_binary" | 
|  | }, | 
|  | { | 
|  | name = "pkgsvr" | 
|  | source = "grand_unified_binary" | 
|  | }, | 
|  | { | 
|  | name = "system-updater" | 
|  | source = "system_updater" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | resources = [ | 
|  | { | 
|  | path = rebase_path("//src/sys/pkg/lib/fuchsia-pkg-testing/certs/ca.cert") | 
|  | dest = "ssl/cert.pem" | 
|  | }, | 
|  | { | 
|  | path = rebase_path("//src/sys/pkg/bin/system-updater/images") | 
|  | dest = "images" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | meta = [ | 
|  | { | 
|  | path = | 
|  | rebase_path("//src/sys/pkg/bin/pkg-cache/meta/pkg-cache-isolated.cmx") | 
|  | dest = "pkg-cache.cmx" | 
|  | }, | 
|  | { | 
|  | path = rebase_path( | 
|  | "//src/sys/pkg/bin/pkg-resolver/meta/pkg-resolver-isolated.cmx") | 
|  | dest = "pkg-resolver.cmx" | 
|  | }, | 
|  | { | 
|  | path = rebase_path( | 
|  | "//src/sys/pkg/bin/system-updater/meta/system-updater-isolated.cmx") | 
|  | dest = "system-updater.cmx" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | log_settings = { | 
|  | max_severity = "ERROR" | 
|  | } | 
|  | name = "isolated_swd_lib_test" | 
|  | dest = "isolated-swd-tests" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | package("isolated-swd-components") { | 
|  | deps = [ | 
|  | "//src/sys/pkg/bin/grand-swd-binary", | 
|  | "//src/sys/pkg/bin/pkg-cache:bin", | 
|  | "//src/sys/pkg/bin/system-updater:bin", | 
|  | ] | 
|  |  | 
|  | binaries = [ | 
|  | { | 
|  | name = "pkg-cache" | 
|  | source = "pkg_cache" | 
|  | }, | 
|  | { | 
|  | name = "pkg-resolver" | 
|  | source = "grand_swd_binary" | 
|  | }, | 
|  | { | 
|  | name = "system-updater" | 
|  | source = "system_updater" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | resources = [ | 
|  | { | 
|  | path = rebase_path("//src/sys/pkg/bin/system-updater/images") | 
|  | dest = "images" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | meta = [ | 
|  | { | 
|  | path = | 
|  | rebase_path("//src/sys/pkg/bin/pkg-cache/meta/pkg-cache-isolated.cmx") | 
|  | dest = "pkg-cache-isolated.cmx" | 
|  | }, | 
|  | { | 
|  | path = rebase_path( | 
|  | "//src/sys/pkg/bin/pkg-resolver/meta/pkg-resolver-isolated.cmx") | 
|  | dest = "pkg-resolver-isolated.cmx" | 
|  | }, | 
|  | { | 
|  | path = rebase_path( | 
|  | "//src/sys/pkg/bin/system-updater/meta/system-updater-isolated.cmx") | 
|  | dest = "system-updater-isolated.cmx" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | group("tests") { | 
|  | testonly = true | 
|  | public_deps = [ | 
|  | ":isolated-swd-tests", | 
|  | "//src/lib/storage/ramdevice_client:ramdisk-isolated-devmgr", | 
|  | ] | 
|  | } |