blob: f512fd766ee113eae58210ea2276213225154492 [file]
# Copyright 2026 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.
load("//build/bazel/rules/rust:rustc_binary.bzl", "rustc_binary")
load("//build/bazel/rules/rust:rustc_library.bzl", "rustc_library")
load("//build/bazel/rules/rust:rustc_test.bzl", "rustc_test")
load("//build/bazel/rules/testing:fx_unittest_package.bzl", "fx_unittest_package")
package(default_applicable_licenses = ["//:license"])
test_suite(
name = "tests",
tests = [":power_cli_tests"],
visibility = ["//src/power:__pkg__"],
)
rustc_library(
name = "lib",
srcs = [
"src/args.rs",
"src/collaborative_reboot/args.rs",
"src/collaborative_reboot/mod.rs",
"src/connector.rs",
"src/debugcmd/args.rs",
"src/debugcmd/mod.rs",
"src/lib.rs",
"src/suspend/args.rs",
"src/suspend/mod.rs",
],
crate_name = "powercli",
edition = "2024",
deps = [
"//sdk/fidl/fuchsia.power:fuchsia.power_rust_flex",
"//sdk/fidl/fuchsia.power.manager.debug:fuchsia.power.manager.debug_rust_flex",
"//sdk/fidl/fuchsia.power.topology.test:fuchsia.power.topology.test_rust_flex",
"//src/developer/ffx/lib/arg_parsing:lib",
"//third_party/rust_crates/vendor:anyhow",
"//third_party/rust_crates/vendor:argh",
],
)
# TODO(https://fxbug.dev/570694755): Restore unit tests for lib_fdomain once
# broken #[cfg(feature = "fdomain")] tests in src/collaborative_reboot/mod.rs
# compile.
rustc_library(
name = "lib_fdomain",
srcs = [
"src/args.rs",
"src/collaborative_reboot/args.rs",
"src/collaborative_reboot/mod.rs",
"src/connector.rs",
"src/debugcmd/args.rs",
"src/debugcmd/mod.rs",
"src/lib.rs",
"src/suspend/args.rs",
"src/suspend/mod.rs",
],
crate_features = ["fdomain"],
crate_name = "powercli",
edition = "2024",
visibility = ["//src/developer/ffx/tools/power:__pkg__"],
deps = [
"//sdk/fidl/fuchsia.power:fuchsia.power_rust_fdomain_flex",
"//sdk/fidl/fuchsia.power.manager.debug:fuchsia.power.manager.debug_rust_fdomain_flex",
"//sdk/fidl/fuchsia.power.topology.test:fuchsia.power.topology.test_rust_fdomain_flex",
"//src/developer/ffx/lib/arg_parsing:lib",
"//third_party/rust_crates/vendor:anyhow",
"//third_party/rust_crates/vendor:argh",
],
)
rustc_binary(
name = "cli",
srcs = ["src/main.rs"],
binary_name = "powerutil",
build_flags = ["//build/config/rust:bootfs"],
edition = "2024",
deps = [
":lib",
"//sdk/fidl/fuchsia.power:fuchsia.power_rust",
"//sdk/fidl/fuchsia.power.manager.debug:fuchsia.power.manager.debug_rust",
"//sdk/fidl/fuchsia.power.topology.test:fuchsia.power.topology.test_rust",
"//src/lib/fuchsia",
"//src/lib/fuchsia-component",
"//third_party/rust_crates/vendor:anyhow",
"//third_party/rust_crates/vendor:argh",
],
)
rustc_test(
name = "lib_test",
crate = ":lib",
# Preserves the GN test binary name from `rustc_library(name = "powercli", with_unit_tests = true)`.
crate_name = "powercli_lib_test",
tags = ["manual"],
target_compatible_with = ["@platforms//os:fuchsia"],
)
fx_unittest_package(
name = "power_cli_tests",
unit_tests = [":lib_test"],
)