| # 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/dist/component_manifest_resources.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_library.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//src/sys/build/components.gni") |
| |
| group("base-resolver") { |
| testonly = true |
| deps = [ ":tests" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":base-resolver-unittests", |
| "tests", |
| ] |
| } |
| |
| base_resolver_deps = [ |
| "//garnet/lib/rust/io_util", |
| "//sdk/fidl/fuchsia.data:fuchsia.data-rustc", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//sdk/fidl/fuchsia.mem:fuchsia.mem-rustc", |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc", |
| "//src/lib/fdio/rust:fdio", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia", |
| "//src/lib/fuchsia-component", |
| "//src/lib/fuchsia-url", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:thiserror", |
| ] |
| |
| rustc_binary("bin") { |
| output_name = "base_resolver" |
| |
| # base-resolver must always be small (even in debug builds) since it is part of the |
| # Zircon boot image. |
| force_opt = "z" |
| configs += [ "//build/config/lto:thinlto" ] |
| configs -= [ "//build/config/lto:thinlto" ] |
| configs += [ "//build/config/lto:thinlto" ] |
| configs -= [ "//build/config/fuchsia:dynamic_rust_standard_library" ] |
| |
| deps = base_resolver_deps |
| |
| sources = [ "src/main.rs" ] |
| } |
| |
| # A separate rule for tests must be used due to an LLVM crash when using thinlto. |
| # TODO(fxbug.dev/64371): Merge back into "bin" target with `with_unit_tests = true`. |
| rustc_test("bin_test") { |
| name = "base-resolver_bin_test" |
| |
| source_root = "src/main.rs" |
| |
| deps = base_resolver_deps + [ |
| ":fake_pkgfs", |
| "//third_party/rust_crates:matches", |
| ] |
| |
| sources = [ "src/main.rs" ] |
| } |
| |
| component_manifest_resources("root-manifest") { |
| sources = [ "meta/base-resolver.cml" ] |
| } |
| |
| fuchsia_component("base-resolver-component") { |
| manifest = "meta/base-resolver.cml" |
| deps = [ ":bin" ] |
| } |
| |
| # Run with `fx test base-resolver-unittests`. |
| fuchsia_unittest_package("base-resolver-unittests") { |
| manifest = "meta/base-resolver-unittests.cml" |
| deps = [ ":bin_test" ] |
| } |
| |
| rustc_library("fake_pkgfs") { |
| source_root = "src/fake_pkgfs.rs" |
| deps = [ |
| "//garnet/lib/rust/io_util", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/storage/vfs/rust:vfs", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//third_party/rust_crates:futures", |
| ] |
| sources = [ "src/fake_pkgfs.rs" ] |
| } |
| |
| group("bootfs") { |
| deps = [ |
| ":bin", |
| ":root-manifest", |
| ] |
| } |