blob: 92cab9cc6ade997090d7d2d4bababc1b689f85b8 [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/images/bootfs_manifest.gni")
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/*",
"//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",
"//sdk/fidl/fuchsia.component:fuchsia.component-rustc",
"//sdk/fidl/fuchsia.component.runner:fuchsia.component.runner-rustc",
"//sdk/fidl/fuchsia.data:fuchsia.data-rustc",
"//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle-rustc",
"//sdk/fidl/fuchsia.security.resource:fuchsia.security.resource-rustc",
"//sdk/fidl/fuchsia.sys:fuchsia.sys-rustc",
"//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc",
"//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc",
"//src/lib/by_addr:by_addr",
"//src/lib/error/clonable_error",
"//src/lib/fdio/rust:fdio",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-runtime",
"//src/lib/fuchsia-url",
"//src/lib/process_builder",
"//src/lib/storage/vfs/rust:vfs",
"//src/lib/trace/rust:trace",
"//src/lib/zircon/rust:fuchsia-zircon",
"//src/lib/zircon/rust:fuchsia-zircon-status",
"//src/lib/zircon/rust:fuchsia-zircon-sys",
"//src/sys/lib/directory_broker",
"//src/sys/lib/library_loader",
"//src/sys/lib/runner",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:async-trait",
"//third_party/rust_crates:byteorder",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:lazy_static",
"//third_party/rust_crates:log",
"//third_party/rust_crates:maplit",
"//third_party/rust_crates:matches",
"//third_party/rust_crates:parking_lot",
"//third_party/rust_crates:rand",
"//third_party/rust_crates:tempfile",
"//third_party/rust_crates:thiserror",
"//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-io2:fuchsia-io2-rustc",
"//zircon/system/fidl/fuchsia-process:fuchsia-process-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",
]
non_rust_deps = [
"//zircon/public/lib/trace",
"//zircon/public/lib/trace-provider-with-fdio",
]
# 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",
"//src/sys/lib/directory_broker",
]
# TODO(47215): Fix the leaks and remove this.
non_rust_deps += [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ]
}
rustc_binary("bin") {
name = "component_manager"
with_unit_tests = true
edition = "2018"
force_opt = "z"
# 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).
configs += [ "//build/config/lto:thinlto" ]
configs -= [ "//build/config/lto:thinlto" ]
configs += [ "//build/config/lto:thinlto" ]
deps = [
":lib",
"//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-runtime",
"//src/lib/storage/pseudo-fs",
"//src/lib/trace/rust:trace-provider",
"//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",
"//zircon/system/fidl/fuchsia-io:fuchsia-io-rustc",
"//zircon/system/fidl/fuchsia-io2:fuchsia-io2-rustc",
]
}
# This manifest is consumed by the ZBI rule in //build/images to add component_manager to bootfs.
bootfs_manifest("component_manager_bootfs.manifest") {
deps = [ ":bin" ]
binaries = [
{
name = "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") {
deps = [ ":bin" ]
binaries = [
{
name = "component_manager"
},
]
meta = [
{
path = rebase_path("meta/component_manager.cmx")
dest = "component_manager.cmx"
},
]
}
test_package("component_manager_tests") {
deps = [
":lib_test",
"//examples/components/basic:hello_world_bin",
"//garnet/examples/fidl/echo_server_rust:echo_server_rust_bin",
"//sdk/fidl/fuchsia.component:fuchsia.component-rustc",
"//src/lib/process_builder:root_job_test_runner",
"//src/lib/process_builder:test_util",
]
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("//garnet/examples/fidl/meta/echo_server.cmx")
dest = "echo_server_rust.cmx"
},
]
binaries = [
{
name = "hello_world"
},
{
name = "process_builder_test_util"
},
{
name = "root_job_test_runner"
},
{
name = "echo_server_rust"
dest = "bin/echo_server"
},
]
}
group("tests") {
testonly = true
deps = [
":component_manager",
":component_manager_tests",
"src/elf_runner/tests",
"tests",
]
}