| # 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/component/config.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") |
| import("//src/sys/build/components.gni") |
| |
| template("component_manager") { |
| deps = [ |
| "//garnet/lib/rust/files_async", |
| "//garnet/lib/rust/io_util", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot-rustc", |
| "//sdk/fidl/fuchsia.component:fuchsia.component-rustc", |
| "//sdk/fidl/fuchsia.component.internal:fuchsia.component.internal-rustc", |
| "//sdk/fidl/fuchsia.component.runner:fuchsia.component.runner-rustc", |
| "//sdk/fidl/fuchsia.data:fuchsia.data-rustc", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//sdk/fidl/fuchsia.io2:fuchsia.io2-rustc", |
| "//sdk/fidl/fuchsia.kernel:fuchsia.kernel-rustc", |
| "//sdk/fidl/fuchsia.logger:fuchsia.logger-rustc", |
| "//sdk/fidl/fuchsia.process:fuchsia.process-rustc", |
| "//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle-rustc", |
| "//sdk/fidl/fuchsia.sys:fuchsia.sys-rustc", |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc", |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc", |
| "//sdk/fidl/fuchsia.time:fuchsia.time-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/scoped_task", |
| "//src/lib/storage/vfs/rust:vfs", |
| "//src/lib/syslog", |
| "//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/cm_fidl_validator", |
| "//src/sys/lib/cm_rust", |
| "//src/sys/lib/cm_types", |
| "//src/sys/lib/component_id_index", |
| "//src/sys/lib/directory_broker", |
| "//src/sys/lib/moniker", |
| "//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", |
| |
| # 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/system/ulib/trace", |
| "//zircon/system/ulib/trace-provider:trace-provider-with-fdio", |
| ] |
| sources = [ |
| "src/builtin/arguments.rs", |
| "src/builtin/capability.rs", |
| "src/builtin/debug_resource.rs", |
| "src/builtin/hypervisor_resource.rs", |
| "src/builtin/info_resource.rs", |
| "src/builtin/ioport_resource.rs", |
| "src/builtin/irq_resource.rs", |
| "src/builtin/kernel_stats.rs", |
| "src/builtin/log.rs", |
| "src/builtin/mmio_resource.rs", |
| "src/builtin/mod.rs", |
| "src/builtin/process_launcher.rs", |
| "src/builtin/root_job.rs", |
| "src/builtin/root_resource.rs", |
| "src/builtin/runner.rs", |
| "src/builtin/smc_resource.rs", |
| "src/builtin/system_controller.rs", |
| "src/builtin/time.rs", |
| "src/builtin/vmex_resource.rs", |
| "src/builtin_environment.rs", |
| "src/capability.rs", |
| "src/capability_ready_notifier.rs", |
| "src/channel.rs", |
| "src/config.rs", |
| "src/constants.rs", |
| "src/elf_runner/mod.rs", |
| "src/framework.rs", |
| "src/fuchsia_boot_resolver.rs", |
| "src/fuchsia_pkg_resolver.rs", |
| "src/klog.rs", |
| "src/lib.rs", |
| "src/model/actions/mod.rs", |
| "src/model/actions/resolve.rs", |
| "src/model/actions/shutdown.rs", |
| "src/model/actions/start.rs", |
| "src/model/actions/stop.rs", |
| "src/model/addable_directory.rs", |
| "src/model/binding.rs", |
| "src/model/component_id_index.rs", |
| "src/model/context.rs", |
| "src/model/dir_tree.rs", |
| "src/model/environment.rs", |
| "src/model/error.rs", |
| "src/model/event_logger.rs", |
| "src/model/events/dispatcher.rs", |
| "src/model/events/error.rs", |
| "src/model/events/event.rs", |
| "src/model/events/filter.rs", |
| "src/model/events/mod.rs", |
| "src/model/events/mode_set.rs", |
| "src/model/events/registry.rs", |
| "src/model/events/running_provider.rs", |
| "src/model/events/serve.rs", |
| "src/model/events/source.rs", |
| "src/model/events/source_factory.rs", |
| "src/model/events/stream.rs", |
| "src/model/events/stream_provider.rs", |
| "src/model/events/synthesizer.rs", |
| "src/model/exposed_dir.rs", |
| "src/model/hooks.rs", |
| "src/model/hub.rs", |
| "src/model/logging.rs", |
| "src/model/mod.rs", |
| "src/model/model.rs", |
| "src/model/namespace.rs", |
| "src/model/policy.rs", |
| "src/model/realm.rs", |
| "src/model/resolver.rs", |
| "src/model/rights.rs", |
| "src/model/routing/error.rs", |
| "src/model/routing/mod.rs", |
| "src/model/routing_fns.rs", |
| "src/model/runner.rs", |
| "src/model/storage/admin_protocol.rs", |
| "src/model/storage/mod.rs", |
| "src/model/testing/echo_service.rs", |
| "src/model/testing/mocks.rs", |
| "src/model/testing/mod.rs", |
| "src/model/testing/out_dir.rs", |
| "src/model/testing/routing_test_helpers.rs", |
| "src/model/testing/test_helpers.rs", |
| "src/model/testing/test_hook.rs", |
| "src/model/walk_state.rs", |
| "src/path.rs", |
| "src/root_realm_stop_notifier.rs", |
| "src/startup.rs", |
| "src/work_scheduler/delegate.rs", |
| "src/work_scheduler/dispatcher.rs", |
| "src/work_scheduler/hook.rs", |
| "src/work_scheduler/mod.rs", |
| "src/work_scheduler/timer.rs", |
| "src/work_scheduler/work_item.rs", |
| "src/work_scheduler/work_scheduler.rs", |
| ] |
| |
| is_test = false |
| if (defined(invoker.is_test)) { |
| is_test = invoker.is_test |
| } |
| |
| if (is_test) { |
| sources += [ |
| "src/model/tests/mod.rs", |
| "src/model/tests/rights.rs", |
| "src/model/tests/routing.rs", |
| "src/model/tests/storage.rs", |
| "src/model/tests/storage_admin.rs", |
| "src/work_scheduler/routing_tests.rs", |
| ] |
| |
| rustc_test(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "non_rust_deps", |
| ]) |
| |
| edition = "2018" |
| |
| # 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. |
| deps += [ |
| "//src/lib/process_builder:test-util-fidl-rustc", |
| "//src/sys/lib/directory_broker", |
| "//src/sys/lib/library_loader", |
| ] |
| } |
| } else { |
| rustc_library(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "non_rust_deps", |
| ]) |
| name = "component_manager_lib" |
| edition = "2018" |
| |
| # Only for internal use. |
| visibility = [ |
| "//src/session/*", |
| "//src/sys/component_manager/*", |
| "//src/sys/component_manager_for_test/*", |
| ] |
| } |
| } |
| } |
| |
| component_manager("lib") { |
| } |
| component_manager("component_manager_test") { |
| is_test = true |
| } |
| component_manager("component_manager_boot_env_test") { |
| is_test = true |
| } |
| |
| 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" ] |
| configs -= [ "//build/config/fuchsia:dynamic_rust_standard_library" ] |
| |
| deps = [ |
| ":lib", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//sdk/fidl/fuchsia.io2:fuchsia.io2-rustc", |
| "//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", |
| ] |
| |
| sources = [ "src/main.rs" ] |
| } |
| |
| # 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. |
| fuchsia_component("component-manager-cmp") { |
| deps = [ |
| ":bin", |
| ":component_manager_appmgr_config", |
| ":component_manager_debug_config", |
| ] |
| component_name = "component_manager" |
| manifest = "meta/component_manager.cmx" |
| } |
| |
| # This component is identical to `component-manager-cmp`, except the manifest |
| # includes the arguments to point component_manager at the bundled config file |
| fuchsia_component("component-manager-for-examples-cmp") { |
| deps = [ |
| ":bin", |
| ":component_manager_for_examples_config", |
| ] |
| component_name = "component_manager_for_examples" |
| manifest = "meta/component_manager_for_examples.cmx" |
| } |
| |
| fuchsia_package("component-manager") { |
| deps = [ ":component-manager-cmp" ] |
| } |
| |
| fuchsia_component("component-manager-tests-cmp") { |
| testonly = true |
| deps = [ |
| ":component_manager_debug_config", |
| ":component_manager_test", |
| "//src/lib/process_builder:test_util", |
| ] |
| component_name = "component_manager_tests" |
| manifest = "meta/component_manager_tests.cmx" |
| } |
| |
| resource("component_manager_tests_invalid_manifest") { |
| sources = [ "meta/component_manager_tests_invalid.cm" ] |
| outputs = [ "meta/{{source_file_part}}" ] |
| } |
| |
| fuchsia_component("component-manager-boot-env-tests-cmp") { |
| testonly = true |
| deps = [ |
| ":component_manager_boot_env_test", |
| ":component_manager_debug_config", |
| "//src/lib/process_builder:root_job_test_runner", |
| "//src/lib/process_builder:test_util", |
| ] |
| component_name = "component_manager_boot_env_tests" |
| manifest = "meta/component_manager_boot_env_tests.cmx" |
| } |
| |
| fuchsia_test_package("component-manager-tests") { |
| test_components = [ |
| ":component-manager-tests-cmp", |
| ":component-manager-boot-env-tests-cmp", |
| ] |
| deps = [ |
| ":component_manager_tests_invalid_manifest", |
| "src/elf_runner/tests:run-indefinitely", |
| "//examples/components/basic:hello-world", |
| "//examples/components/basic:lifecycle-full", |
| "//garnet/examples/fidl/echo_server_rust:echo-server-rust-cmp", |
| ] |
| } |
| |
| group("tests") { |
| testonly = true |
| |
| deps = [ |
| ":component-manager", |
| ":component-manager-tests", |
| "src/elf_runner/tests", |
| "stress_tests", |
| "testing:test-utils-unittests", |
| "tests", |
| ] |
| } |
| |
| group("bootfs") { |
| deps = [ |
| ":bin", |
| "//src/sys/startup:bootfs", |
| ] |
| } |
| |
| component_config("component_manager_appmgr_config") { |
| sources = [ "configs/appmgr_config.json" ] |
| } |
| |
| component_config("component_manager_debug_config") { |
| sources = [ "configs/debug_config.json" ] |
| } |
| |
| component_config("component_manager_bootfs_config") { |
| sources = [ |
| "//src/security/policy/component_manager_policy.json", |
| "configs/bootfs_config.json", |
| ] |
| dest = "config/component_manager" |
| } |
| |
| component_config("component_manager_for_examples_config") { |
| sources = [ "configs/for_examples_config.json" ] |
| dest = "data/component_manager_config" |
| } |