| # 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/platforms:constraints.bzl", "HOST_OS_CONSTRAINTS") | |
| load( | |
| "//build/bazel/rules/components:fx_component.bzl", | |
| "fx_component_manifest", | |
| "fx_test_component", | |
| ) | |
| load("//build/bazel/rules/packages:fx_package.bzl", "fx_package") | |
| load( | |
| "//build/bazel/rules/packages:fx_packaged_binary.bzl", | |
| "fx_packaged_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_test.bzl", "fx_test") | |
| package(default_applicable_licenses = ["//:license"]) | |
| _COMMON_SRCS = [ | |
| "src/capability.rs", | |
| "src/cli/capability.rs", | |
| "src/cli/collection.rs", | |
| "src/cli/config.rs", | |
| "src/cli/create.rs", | |
| "src/cli/destroy.rs", | |
| "src/cli/doctor.rs", | |
| "src/cli/explore.rs", | |
| "src/cli/format.rs", | |
| "src/cli/graph.rs", | |
| "src/cli/list.rs", | |
| "src/cli/mod.rs", | |
| "src/cli/reload.rs", | |
| "src/cli/resolve.rs", | |
| "src/cli/route.rs", | |
| "src/cli/run.rs", | |
| "src/cli/show.rs", | |
| "src/cli/start.rs", | |
| "src/cli/stop.rs", | |
| "src/cli/storage.rs", | |
| "src/config.rs", | |
| "src/copy.rs", | |
| "src/dirs.rs", | |
| "src/doctor.rs", | |
| "src/explore.rs", | |
| "src/io.rs", | |
| "src/lib.rs", | |
| "src/lifecycle.rs", | |
| "src/path.rs", | |
| "src/query.rs", | |
| "src/realm.rs", | |
| "src/route.rs", | |
| "src/storage/copy.rs", | |
| "src/storage/delete.rs", | |
| "src/storage/delete_all.rs", | |
| "src/storage/list.rs", | |
| "src/storage/make_directory.rs", | |
| "src/storage/mod.rs", | |
| "src/test_utils.rs", | |
| ] | |
| # @bazel2gn:transformer=deps | |
| _COMMON_DEPS = [ | |
| "//sdk/rust/zx-status", | |
| "//src/lib/directed_graph", | |
| "//src/lib/fidl/rust/fidl", | |
| "//src/lib/fuchsia-async", | |
| "//src/lib/fuchsia-url", | |
| "//src/sys/lib/cm_fidl_validator", | |
| "//src/sys/lib/cm_rust", | |
| "//src/sys/lib/cm_types", | |
| "//src/sys/lib/moniker", | |
| "//src/sys/lib/socket-to-stdio", | |
| "//third_party/rust_crates/forks/prettytable-rs:prettytable", | |
| "//third_party/rust_crates/vendor:ansi_term", | |
| "//third_party/rust_crates/vendor:anyhow", | |
| "//third_party/rust_crates/vendor:futures", | |
| "//third_party/rust_crates/vendor:regex-lite", | |
| "//third_party/rust_crates/vendor:serde_json", | |
| "//third_party/rust_crates/vendor:textwrap", | |
| "//third_party/rust_crates/vendor:thiserror", | |
| "//third_party/rust_crates/vendor:url", | |
| "//tools/lib/config_value_file", | |
| ] + select({ | |
| "//build/bazel/platforms:is_host_os": [ | |
| "//third_party/rust_crates/vendor:schemars", | |
| "//third_party/rust_crates/vendor:serde", | |
| ], | |
| "//conditions:default": [], | |
| }) | |
| # Some host tools use serde to serialize/deserialize types. This | |
| # dependency is guarded in code via #[cfg(feature = "serde")] and | |
| # #[cfg_attr(feature = "serde", ...)] to prevent serde dependencies in | |
| # non-host builds. | |
| rustc_library( | |
| name = "component_debug", | |
| srcs = _COMMON_SRCS, | |
| crate_features = select({ | |
| "//build/bazel/platforms:is_host_os": ["serde"], | |
| "//conditions:default": [], | |
| }), | |
| edition = "2024", | |
| proc_macro_deps = ["//third_party/rust_crates/vendor:async-trait"], | |
| tags = [ | |
| # The component internal API should not be exposed to this library | |
| "assert_no_deps=//sdk/fidl/fuchsia.component.internal:fuchsia.component.internal_rust", | |
| # Should not need to bring in the entire routing crate. This crate is used | |
| # by the client, the backend is responsible for routing | |
| "assert_no_deps=//src/sys/lib/routing", | |
| ], | |
| visibility = [ | |
| "//src/connectivity:__subpackages__", | |
| "//src/developer:__subpackages__", | |
| "//src/diagnostics:__subpackages__", | |
| "//src/session:__subpackages__", | |
| "//src/storage:__subpackages__", | |
| "//src/sys:__subpackages__", | |
| "//src/testing/sl4f:__pkg__", | |
| ], | |
| deps = _COMMON_DEPS + [ | |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_rust_flex", | |
| "//sdk/fidl/fuchsia.component:fuchsia.component_rust_flex", | |
| "//sdk/fidl/fuchsia.dash:fuchsia.dash_rust_flex", | |
| "//sdk/fidl/fuchsia.data:fuchsia.data_rust_flex", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust_flex", | |
| "//sdk/fidl/fuchsia.process:fuchsia.process_rust_flex", | |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2_rust_flex", | |
| "//src/lib/fdomain/client:flex_fidl", | |
| "//src/lib/fuchsia-fs", | |
| ], | |
| ) | |
| rustc_library( | |
| name = "component_debug_fdomain", | |
| srcs = _COMMON_SRCS, | |
| crate_features = ["fdomain"] + select({ | |
| "//build/bazel/platforms:is_host_os": ["serde"], | |
| "//conditions:default": [], | |
| }), | |
| edition = "2024", | |
| proc_macro_deps = ["//third_party/rust_crates/vendor:async-trait"], | |
| tags = [ | |
| # The component internal API should not be exposed to this library | |
| "assert_no_deps=//sdk/fidl/fuchsia.component.internal:fuchsia.component.internal_rust", | |
| # Should not need to bring in the entire routing crate. This crate is used | |
| # by the client, the backend is responsible for routing | |
| "assert_no_deps=//src/sys/lib/routing", | |
| ], | |
| # `component_debug_fdomain` links `fuchsia-fs_fdomain` (which omits | |
| # `fuchsia_fs::directory::open_in_namespace` on Fuchsia) and only builds on | |
| # host; skipped in `bazel2gn` because `BUILD.gn` defines it outside `if (is_host)`. | |
| # @bazel2gn:skip | |
| target_compatible_with = HOST_OS_CONSTRAINTS, | |
| visibility = [ | |
| "//src/developer/ffx:__subpackages__", | |
| "//src/diagnostics/iquery:__pkg__", | |
| "//src/diagnostics/lib/log-command:__pkg__", | |
| "//src/sys/run_test_suite:__pkg__", | |
| ], | |
| deps = _COMMON_DEPS + [ | |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_rust_fdomain_flex", | |
| "//sdk/fidl/fuchsia.component:fuchsia.component_rust_fdomain_flex", | |
| "//sdk/fidl/fuchsia.dash:fuchsia.dash_rust_fdomain_flex", | |
| "//sdk/fidl/fuchsia.data:fuchsia.data_rust_fdomain_flex", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust_fdomain_flex", | |
| "//sdk/fidl/fuchsia.process:fuchsia.process_rust_fdomain_flex", | |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2_rust_fdomain_flex", | |
| "//src/lib/fdomain/client:flex_fdomain", | |
| "//src/lib/fuchsia-fs:fuchsia-fs_fdomain", | |
| ], | |
| ) | |
| rustc_test( | |
| name = "component_debug_test", | |
| crate = ":component_debug", | |
| crate_features = select({ | |
| "//build/bazel/platforms:is_host_os": ["serde"], | |
| "//conditions:default": [], | |
| }), | |
| # Sets GN `output_name` to match `bin/component_debug_lib_test` in `meta/unittests.cml`. | |
| crate_name = "component_debug_lib_test", | |
| target_compatible_with = ["@platforms//os:fuchsia"], | |
| deps = [ | |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_rust", | |
| "//src/lib/fdio/rust:fdio", | |
| "//src/lib/fidl/rust/fidl", | |
| "//src/lib/fuchsia", | |
| "//src/sys/lib/cm_rust/testing", | |
| "//third_party/rust_crates/vendor:assert_matches", | |
| "//third_party/rust_crates/vendor:pretty_assertions", | |
| "//third_party/rust_crates/vendor:tempfile", | |
| "//third_party/rust_crates/vendor:test-case", | |
| ], | |
| ) | |
| fx_packaged_binary( | |
| name = "component_debug_test_packaged_bin", | |
| testonly = True, | |
| binary = ":component_debug_test", | |
| binary_name = "component_debug_lib_test", | |
| ) | |
| fx_component_manifest( | |
| name = "component_debug_unittests-manifest", | |
| testonly = True, | |
| component_name = "component_debug_unittests", | |
| includes = [ | |
| "//sdk/lib/syslog:client.shard", | |
| "//src/sys/test_runners/rust:default.shard.cml", | |
| ], | |
| manifest = "meta/unittests.cml", | |
| ) | |
| fx_test_component( | |
| name = "component_debug_unittests-component", | |
| compiled_manifest = ":component_debug_unittests-manifest", | |
| deps = [":component_debug_test_packaged_bin"], | |
| ) | |
| fx_package( | |
| name = "component_debug_unittests-package", | |
| package_name = "component_debug_unittests", | |
| test_components = [":component_debug_unittests-component"], | |
| ) | |
| fx_test( | |
| name = "component_debug_unittests", | |
| package = ":component_debug_unittests-package", | |
| visibility = ["//src/sys:__pkg__"], | |
| ) |