| # 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_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"]) | |
| rustc_library( | |
| name = "routing", | |
| srcs = [ | |
| "src/availability.rs", | |
| "src/bedrock/aggregate_router.rs", | |
| "src/bedrock/dict_ext.rs", | |
| "src/bedrock/mod.rs", | |
| "src/bedrock/program_output_dict.rs", | |
| "src/bedrock/request_metadata.rs", | |
| "src/bedrock/sandbox_construction.rs", | |
| "src/bedrock/structured_dict.rs", | |
| "src/bedrock/use_dictionary_router.rs", | |
| "src/bedrock/weak_instance_token_ext.rs", | |
| "src/bedrock/with_policy_check.rs", | |
| "src/bedrock/with_service_renames_and_filter.rs", | |
| "src/component_instance.rs", | |
| "src/config.rs", | |
| "src/error.rs", | |
| "src/error_logging_router.rs", | |
| "src/intermediate_router.rs", | |
| "src/lib.rs", | |
| "src/policy.rs", | |
| "src/resolving.rs", | |
| "src/rights.rs", | |
| "src/subdir.rs", | |
| "src/to_request.rs", | |
| "src/to_source.rs", | |
| ], | |
| # Some host tools use serde to serialize/deserialize types defined in | |
| # this crate. This dependency is guarded in code via #[cfg(feature = "serde")] | |
| # and #[cfg_attr(feature = "serde", ...)] to prevent serde dependencies in | |
| # non-host builds. | |
| crate_features = select({ | |
| "//build/bazel/platforms:is_host_os": ["serde"], | |
| "//conditions:default": [], | |
| }), | |
| edition = "2024", | |
| proc_macro_deps = [ | |
| "//src/sys/lib/cm_rust:cm_rust_derive", | |
| "//third_party/rust_crates/vendor:async-trait", | |
| "//third_party/rust_crates/vendor:derivative", | |
| ], | |
| visibility = [ | |
| "//src/security/lib/scrutiny/frontend:__pkg__", | |
| "//src/sys:__subpackages__", | |
| "//tools/lib/cm_fidl_analyzer:__subpackages__", | |
| ], | |
| deps = [ | |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_rust_common", | |
| "//sdk/fidl/fuchsia.component:fuchsia.component_rust_common", | |
| "//sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_rust_common", | |
| "//sdk/fidl/fuchsia.component.runtime:fuchsia.component.runtime_rust_common", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust_common", | |
| "//sdk/rust/zx-status", | |
| "//src/lib/directed_graph", | |
| "//src/lib/error/clonable_error", | |
| "//src/lib/fidl/rust/fidl", | |
| "//src/lib/fuchsia-sync", | |
| "//src/lib/versioning/version-history/rust", | |
| "//src/sys/component_manager/lib/router_error", | |
| "//src/sys/lib/capability_source", | |
| "//src/sys/lib/cm_config", | |
| "//src/sys/lib/cm_graph", | |
| "//src/sys/lib/cm_rust", | |
| "//src/sys/lib/cm_types", | |
| "//src/sys/lib/component_id_index", | |
| "//src/sys/lib/moniker", | |
| "//src/sys/lib/routing/availability", | |
| "//src/sys/lib/runtime_capabilities", | |
| "//third_party/rust_crates/vendor:anyhow", | |
| "//third_party/rust_crates/vendor:futures", | |
| "//third_party/rust_crates/vendor:itertools", | |
| "//third_party/rust_crates/vendor:log", | |
| "//third_party/rust_crates/vendor:smallbox", | |
| "//third_party/rust_crates/vendor:thiserror", | |
| "//third_party/rust_crates/vendor:url", | |
| ] + select({ | |
| "//build/bazel/platforms:is_host_os": [ | |
| "//third_party/rust_crates/vendor:serde", | |
| ], | |
| "//conditions:default": [], | |
| }) + select({ | |
| "@platforms//os:fuchsia": [ | |
| "//sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_rust", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust", | |
| "//sdk/fidl/fuchsia.mem:fuchsia.mem_rust", | |
| "//src/lib/trace/rust:trace", | |
| "//src/storage/lib/vfs/rust:vfs", | |
| "//src/sys/lib/cm_fidl_validator", | |
| "//src/sys/lib/mem_util", | |
| ], | |
| "//conditions:default": [], | |
| }), | |
| ) | |
| rustc_test( | |
| name = "routing_test", | |
| # Propagates `tmp_storage.shard.cml` to `fx_unittest_package` in Bazel and | |
| # maps to `deps` in GN via bazel2gn. | |
| aspect_hints = ["//src/sys/test_runners:tmp_storage"], | |
| crate = ":routing", | |
| crate_features = select({ | |
| "//build/bazel/platforms:is_host_os": ["serde"], | |
| "//conditions:default": [], | |
| }), | |
| edition = "2024", | |
| deps = [ | |
| "//src/lib/fuchsia", | |
| "//src/sys/lib/cm_rust/testing", | |
| "//third_party/rust_crates/vendor:assert_matches", | |
| "//third_party/rust_crates/vendor:serde_json", | |
| "//third_party/rust_crates/vendor:test-case", | |
| ], | |
| ) | |
| fx_unittest_package( | |
| name = "fuchsia-routing-tests", | |
| unit_tests = [":routing_test"], | |
| ) |