| # 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/config.gni") |
| import("//build/dist/component_manifest_resources.gni") |
| import("//build/package.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//build/test/test_package.gni") |
| import("//third_party/cobalt/metrics_registry.gni") |
| |
| metrics_registry("power_manager_metrics") { |
| # ID of the 'power' project from the //third_party/cobalt_config/projects.yaml file |
| project_id = 3 |
| |
| # The namespace to use in the generated code |
| namespace = "power_manager_metrics" |
| |
| # Generates a rust target called 'power_manager_metrics_rustlib' |
| generate_rust = true |
| } |
| |
| rustc_binary("bin") { |
| name = "power_manager" |
| edition = "2018" |
| force_opt = "z" |
| |
| # TODO(fxbug.dev/64097): extract to a template |
| # power_manager must always be small (even in debug builds) since it is part of bootfs. |
| # |
| # The add/remove/add ensures we get the configuration without producing errors for builds which |
| # enable ThinLTO themselves. |
| configs += [ "//build/config/lto:thinlto" ] |
| configs -= [ "//build/config/lto:thinlto" ] |
| configs += [ "//build/config/lto:thinlto" ] |
| |
| # we can't dynamically link std when we're in the zbi |
| configs -= [ "//build/config/fuchsia:dynamic_rust_standard_library" ] |
| |
| deps = [ |
| ":power_manager_metrics_rustlib", |
| "//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt-rustc", |
| "//sdk/fidl/fuchsia.device:fuchsia.device-rustc", |
| "//sdk/fidl/fuchsia.device.manager:fuchsia.device.manager-rustc", |
| "//sdk/fidl/fuchsia.feedback:fuchsia.feedback-rustc", |
| "//sdk/fidl/fuchsia.hardware.cpu.ctrl:fuchsia.hardware.cpu.ctrl-rustc", |
| "//sdk/fidl/fuchsia.hardware.power.statecontrol:fuchsia.hardware.power.statecontrol-rustc", |
| "//sdk/fidl/fuchsia.hardware.thermal:fuchsia.hardware.thermal-rustc", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//sdk/fidl/fuchsia.kernel:fuchsia.kernel-rustc", |
| "//sdk/fidl/fuchsia.power.manager:fuchsia.power.manager-rustc", |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc", |
| "//sdk/fidl/fuchsia.thermal:fuchsia.thermal-rustc", |
| "//src/lib/cobalt/rust:fuchsia-cobalt", |
| "//src/lib/diagnostics/inspect/contrib/rust", |
| "//src/lib/diagnostics/inspect/rust", |
| "//src/lib/fdio/rust:fdio", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/syslog/rust", |
| "//src/lib/trace/rust:trace", |
| "//src/lib/trace/rust:trace-provider", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:async-trait", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:lazy_static", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:num-traits", |
| "//third_party/rust_crates:parking_lot", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_derive", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:thiserror", |
| ] |
| |
| sources = [ |
| "src/cobalt_metrics.rs", |
| "src/cpu_control_handler.rs", |
| "src/cpu_stats_handler.rs", |
| "src/crash_report_handler.rs", |
| "src/dev_control_handler.rs", |
| "src/driver_manager_handler.rs", |
| "src/error.rs", |
| "src/main.rs", |
| "src/message.rs", |
| "src/node.rs", |
| "src/power_manager.rs", |
| "src/shutdown_request.rs", |
| "src/shutdown_watcher.rs", |
| "src/system_shutdown_handler.rs", |
| "src/temperature_handler.rs", |
| "src/test/mock_node.rs", |
| "src/test/mod.rs", |
| "src/test/thermal_integration_tests.rs", |
| "src/thermal_limiter.rs", |
| "src/thermal_policy.rs", |
| "src/thermal_shutdown.rs", |
| "src/types.rs", |
| "src/utils.rs", |
| ] |
| } |
| |
| # TODO(fxbug.dev/64371): Require a standalone rustc_test target here instead of adding |
| # "with_unit_tests = true" to the rustc_binary target above because of a bug that leads to a |
| # segmentation fault related to the thinlto configuration. See fxbug.dev/64371 for more details. |
| rustc_test("bin_test") { |
| name = "power_manager_bin_test" |
| edition = "2018" |
| source_root = "src/main.rs" |
| |
| deps = [ |
| ":power_manager_metrics_rustlib", |
| "rkf45:lib", |
| "//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt-rustc", |
| "//sdk/fidl/fuchsia.device:fuchsia.device-rustc", |
| "//sdk/fidl/fuchsia.device.manager:fuchsia.device.manager-rustc", |
| "//sdk/fidl/fuchsia.feedback:fuchsia.feedback-rustc", |
| "//sdk/fidl/fuchsia.hardware.cpu.ctrl:fuchsia.hardware.cpu.ctrl-rustc", |
| "//sdk/fidl/fuchsia.hardware.power.statecontrol:fuchsia.hardware.power.statecontrol-rustc", |
| "//sdk/fidl/fuchsia.hardware.thermal:fuchsia.hardware.thermal-rustc", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//sdk/fidl/fuchsia.kernel:fuchsia.kernel-rustc", |
| "//sdk/fidl/fuchsia.power.manager:fuchsia.power.manager-rustc", |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2-rustc", |
| "//sdk/fidl/fuchsia.thermal:fuchsia.thermal-rustc", |
| "//src/lib/cobalt/rust:fuchsia-cobalt", |
| "//src/lib/diagnostics/inspect/contrib/rust", |
| "//src/lib/diagnostics/inspect/rust", |
| "//src/lib/fdio/rust:fdio", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/storage/vfs/rust:vfs", |
| "//src/lib/syslog/rust", |
| "//src/lib/test_util", |
| "//src/lib/trace/rust:trace", |
| "//src/lib/trace/rust:trace-provider", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:async-trait", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:lazy_static", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:matches", |
| "//third_party/rust_crates:num-traits", |
| "//third_party/rust_crates:parking_lot", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_derive", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:thiserror", |
| ] |
| |
| sources = [ |
| "src/cobalt_metrics.rs", |
| "src/cpu_control_handler.rs", |
| "src/cpu_stats_handler.rs", |
| "src/crash_report_handler.rs", |
| "src/dev_control_handler.rs", |
| "src/driver_manager_handler.rs", |
| "src/error.rs", |
| "src/main.rs", |
| "src/message.rs", |
| "src/node.rs", |
| "src/power_manager.rs", |
| "src/shutdown_request.rs", |
| "src/shutdown_watcher.rs", |
| "src/system_shutdown_handler.rs", |
| "src/temperature_handler.rs", |
| "src/test/mock_node.rs", |
| "src/test/mod.rs", |
| "src/test/thermal_integration_tests.rs", |
| "src/thermal_limiter.rs", |
| "src/thermal_policy.rs", |
| "src/thermal_shutdown.rs", |
| "src/types.rs", |
| "src/utils.rs", |
| ] |
| } |
| |
| component_manifest_resources("manifest") { |
| sources = [ "meta/power-manager.cml" ] |
| } |
| |
| group("power-manager") { |
| testonly = true |
| deps = [ |
| ":bin", |
| ":tests", |
| ] |
| } |
| |
| group("bootfs") { |
| deps = [ |
| ":bin", |
| ":manifest", |
| ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":power-manager-tests", |
| "rkf45:rkf45-tests", |
| ] |
| } |
| |
| test_package("power-manager-tests") { |
| deps = [ |
| ":bin_test", |
| "node_config:test_config_data", |
| ] |
| |
| tests = [ |
| { |
| name = "power_manager_bin_test" |
| }, |
| ] |
| } |
| |
| group("astro_config") { |
| deps = [ "node_config:astro" ] |
| } |
| |
| group("base_config") { |
| deps = [ "node_config:base" ] |
| } |
| |
| group("luis_config") { |
| deps = [ "node_config:luis" ] |
| } |
| |
| group("nelson_config") { |
| deps = [ "node_config:nelson" ] |
| } |
| |
| group("sherlock_config") { |
| deps = [ "node_config:sherlock" ] |
| } |