| # Copyright 2021 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/components.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/tools/gzip/gzip.gni") |
| import("//src/starnix/build/args.gni") |
| |
| group("kernel") { |
| deps = [ ":starnix_kernel_package" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| |
| deps = [ |
| ":starnix_kernel_bin-tests", |
| "core:tests", |
| "runner:tests", |
| "syscall_loop:tests", |
| ] |
| } |
| |
| rustc_binary("starnix_kernel_bin") { |
| name = "starnix_kernel" |
| edition = "2024" |
| with_unit_tests = true |
| |
| # TODO(https://fxbug.dev/42059075): Re-enable starnix in these environments. |
| exclude_toolchain_tags = [ |
| "asan", |
| "hwasan", |
| ] |
| |
| source_root = "main.rs" |
| deps = [ |
| ":android_5.10_kernel_config", |
| ":starnix_kernel_structured_config", |
| "//sdk/fidl/fuchsia.component.runner:fuchsia.component.runner_rust", |
| "//sdk/fidl/fuchsia.memory.attribution:fuchsia.memory.attribution_rust", |
| "//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_rust", |
| "//sdk/fidl/fuchsia.starnix.container:fuchsia.starnix.container_rust", |
| "//sdk/rust/zx", |
| "//src/lib/diagnostics/inspect/runtime/rust", |
| "//src/lib/diagnostics/inspect/rust", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/fuchsia-runtime", |
| "//src/lib/trace/rust:trace", |
| "//src/lib/trace/rust:trace-provider", |
| "//src/starnix/kernel/core", |
| "//src/starnix/kernel/runner:starnix_kernel_runner", |
| "//src/starnix/lib/extended_pstate:lib", |
| "//src/starnix/lib/starnix_logging", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:async-lock", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:tracing-mutex", |
| ] |
| |
| sources = [ "main.rs" ] |
| |
| configs += [ |
| "//build/config/rust/lints:clippy_warn_all", |
| "//src/starnix/config:starnix_clippy_lints", |
| ] |
| |
| # Enable moderate level of optimization for better performance. |
| if (compilation_mode == "release") { |
| configs += [ "//build/config:optimize_moderate" ] |
| } |
| |
| disable_rustdoc = false |
| |
| if (compilation_mode == "release" || target_cpu == "riscv64" || |
| is_lto_variant) { |
| # LTO is enabled in release mode, and remote linking requires machines with more memory, |
| # particularly in the linking phase at least for riscv64 and LTO. |
| _concurrent_jobs = concurrent_jobs.rust_highmem |
| configs += _concurrent_jobs.configs |
| forward_variables_from(_concurrent_jobs.vars, "*") |
| } |
| } |
| |
| # Components |
| |
| # The starnix kernel manifest, used by all containers. |
| fuchsia_component_manifest("starnix_kernel_manifest") { |
| # tracing-mutex doesn't produce very useful debugging information when |
| # backtraces are disabled, so we enable them when tracing-mutex is enabled. |
| if (starnix_enable_rust_backtrace) { |
| manifest = "meta/starnix_kernel_with_rust_backtrace.cml" |
| } else { |
| manifest = "meta/starnix_kernel.cml" |
| } |
| component_name = "starnix_kernel" |
| } |
| |
| gzip("gzip_android_5.10_kernel_config") { |
| input = "data/config" |
| output = "$target_gen_dir/config.gz" |
| } |
| |
| resource("android_5.10_kernel_config") { |
| sources = [ "$target_gen_dir/config.gz" ] |
| outputs = [ "data/config.gz" ] |
| deps = [ ":gzip_android_5.10_kernel_config" ] |
| } |
| |
| fuchsia_component_manifest("empty_container_manifest") { |
| manifest = "//src/starnix/containers/empty_container/meta/empty_container.cml" |
| } |
| |
| fuchsia_structured_config_rust_lib("starnix_container_structured_config") { |
| cm_label = ":empty_container_manifest" |
| } |
| |
| fuchsia_structured_config_rust_lib("starnix_kernel_structured_config") { |
| cm_label = ":starnix_kernel_manifest" |
| } |
| |
| fuchsia_component("starnix_kernel") { |
| cm_label = ":starnix_kernel_manifest" |
| deps = [ ":starnix_kernel_bin" ] |
| } |
| |
| # Packages |
| |
| fuchsia_package("starnix_kernel_package") { |
| package_name = "starnix_kernel" |
| deps = [ |
| ":starnix_kernel", |
| "//src/starnix/containers:default_init", |
| ] |
| } |
| |
| fuchsia_unittest_package("starnix_kernel_bin-tests") { |
| deps = [ ":starnix_kernel_bin_test" ] |
| manifest = "meta/starnix_kernel_bin_tests.cml" |
| } |