blob: fdb21b408b9c5daedda83fd49c651a7c0fcdc21b [file] [log] [blame]
# Copyright 2019 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_binary.gni")
import("//build/rust/rustc_library.gni")
import("//build/test/test_package.gni")
import("//build/testing/environments.gni")
rustc_library("lib") {
name = "component_manager_lib"
with_unit_tests = true
edition = "2018"
# Only for internal use.
visibility = [
"//src/session/component_manager/*",
"//src/sys/component_manager/*",
"//src/sys/component_manager_for_test/*",
]
deps = [
"//garnet/lib/rust/cm_fidl_translator",
"//garnet/lib/rust/cm_fidl_validator",
"//garnet/lib/rust/cm_rust",
"//garnet/lib/rust/files_async",
"//garnet/lib/rust/io_util",
"//garnet/public/lib/fidl/rust/fidl",
"//garnet/public/rust/fdio",
"//garnet/public/rust/fuchsia-async",
"//garnet/public/rust/fuchsia-component",
"//garnet/public/rust/fuchsia-runtime",
"//garnet/public/rust/fuchsia-vfs/pseudo-fs",
"//garnet/public/rust/fuchsia-zircon",
"//garnet/public/rust/fuchsia-zircon/fuchsia-zircon-sys",
"//sdk/fidl/fuchsia.data:fuchsia.data-rustc",
"//sdk/fidl/fuchsia.sys:fuchsia.sys-rustc",
"//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc",
"//src/lib/by_addr:by_addr",
"//src/lib/error/clonable_error",
"//src/lib/process_builder",
"//src/sys/lib/fuchsia_url:fuchsia_url",
"//src/sys/lib/library_loader:library_loader",
"//third_party/rust_crates:async-trait",
"//third_party/rust_crates:byteorder",
"//third_party/rust_crates:failure",
"//third_party/rust_crates:futures-preview",
"//third_party/rust_crates:lazy_static",
"//third_party/rust_crates:log",
"//third_party/rust_crates:rand",
"//third_party/rust_crates:tempfile",
"//third_party/rust_crates:url",
"//third_party/rust_crates:void",
"//zircon/system/fidl/fuchsia-boot:fuchsia-boot-rustc",
"//zircon/system/fidl/fuchsia-io:fuchsia-io-rustc",
"//zircon/system/fidl/fuchsia-process:fuchsia-process-rustc",
"//zircon/system/fidl/fuchsia-security-resource:fuchsia-security-resource-rustc",
# This is a 'logical' test-only dep, in that it's only used in the
# model::testing helpers, but that module is currently included in the main
# library (rather than being guarded with '#[cfg(test)]') to allow use in
# separate integration test targets.
"//garnet/examples/fidl/services:echo-rustc",
]
# Test-only deps. Prefer adding deps used only in tests here instead of
# above, which has the benefit of keeping unneeded deps out of the production
# binary and allows depending on 'testonly' targets.
test_deps = [ "//src/lib/process_builder:test-util-fidl-rustc" ]
}
rustc_binary("bin") {
name = "component_manager"
with_unit_tests = true
edition = "2018"
# Component manager must always be small (even in debug builds) since it
# is part of the Zircon boot image.
#
# We use a Thin LTO, which provides a ~65% decrease in binary size, albeit at
# the cost of a ~5x increase in compile wall time (or roughly 10 seconds on
# a 2018-era workstation). Fat LTO provides an even smaller binary (~70%
# decrease from no-LTO), but is single threaded, requiring ~6x more wall time
# to build (or roughly 60 seconds on a 2018-era workstation).
force_opt = "z"
with_lto = "thin"
deps = [
":lib",
"//garnet/public/lib/fidl/rust/fidl",
"//garnet/public/rust/fuchsia-async",
"//garnet/public/rust/fuchsia-runtime",
"//garnet/public/rust/fuchsia-vfs/pseudo-fs",
"//third_party/rust_crates:failure",
"//third_party/rust_crates:futures-preview",
"//third_party/rust_crates:log",
"//zircon/system/fidl/fuchsia-io:fuchsia-io-rustc",
]
}
# This manifest is consumed by the ZBI rule in //build/images to add component_manager to bootfs.
generate_manifest("component_manager.bootfs") {
deps = [
":bin",
]
args = [ "--entry=bin/component_manager=" +
rebase_path("$root_build_dir/component_manager", root_build_dir) ]
}
deprecated_fuchsia_component("component_manager_as_v1_component") {
deps = [
":bin",
]
manifest = rebase_path("meta/component_manager.cmx")
binary = "component_manager"
}
# Note that this package and the component it contains wrap component_manager
# as a v1 Component for interactive testing purposes through the shell. This
# will eventually go away.
package("component_manager") {
components = [ ":component_manager_as_v1_component" ]
}
test_package("component_manager_tests") {
rootjob_svc = "//build"
rootresource_svc = "//build"
deps = [
":lib_test",
"//examples/components/basic:hello_world_bin",
"//src/lib/process_builder:root_job_test_runner",
"//src/lib/process_builder:test_util",
"//src/sys/component_manager/tests/memfs",
]
components =
[ "//garnet/examples/fidl/echo_server_rust:echo_server_rust_component" ]
tests = [
{
name = "component_manager_lib_lib_test"
dest = "component_manager_tests"
environments = basic_envs
},
{
name = "component_manager_lib_lib_test"
dest = "component_manager_boot_env_tests"
environments = basic_envs
},
]
resources = [
{
path = rebase_path("meta/component_manager_tests_invalid.cm")
dest = "component_manager_tests_invalid.cm"
},
]
meta = [
{
path = rebase_path("meta/component_manager_tests_hello_world.cml")
dest = "component_manager_tests_hello_world.cm"
},
{
path = rebase_path("meta/memfs.cmx")
dest = "memfs.cmx"
},
]
binaries = [
{
name = "hello_world"
},
{
name = "process_builder_test_util"
},
{
name = "root_job_test_runner"
},
{
name = "memfs"
},
]
}
group("tests") {
testonly = true
deps = [
":component_manager_tests",
"tests",
]
}