| # 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/components:fx_component.bzl", | |
| "fx_component", | |
| "fx_component_manifest", | |
| ) | |
| 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_binary.bzl", | |
| "rustc_binary", | |
| ) | |
| package(default_applicable_licenses = ["//:license"]) | |
| rustc_binary( | |
| name = "lifecycle_example", | |
| srcs = ["src/lifecycle.rs"], | |
| binary_name = "lifecycle_example_rust", | |
| crate_root = "src/lifecycle.rs", | |
| edition = "2024", | |
| target_compatible_with = ["@platforms//os:fuchsia"], | |
| deps = [ | |
| "//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_rust", | |
| "//sdk/rust/zx", | |
| "//src/lib/fidl/rust/fidl", | |
| "//src/lib/fuchsia", | |
| "//src/lib/fuchsia-async", | |
| "//src/lib/fuchsia-component", | |
| "//src/lib/fuchsia-runtime", | |
| "//third_party/rust_crates/vendor:anyhow", | |
| "//third_party/rust_crates/vendor:futures-util", | |
| "//third_party/rust_crates/vendor:log", | |
| ], | |
| ) | |
| fx_packaged_binary( | |
| name = "lifecycle_example_packaged", | |
| binary = ":lifecycle_example", | |
| binary_name = "lifecycle_example_rust", | |
| ) | |
| fx_component_manifest( | |
| name = "lifecycle-component_manifest", | |
| component_name = "default", | |
| includes = [ | |
| "//sdk/lib/syslog:client.shard", | |
| ], | |
| manifest = "meta/lifecycle.cml", | |
| ) | |
| fx_component( | |
| name = "lifecycle-component", | |
| compiled_manifest = ":lifecycle-component_manifest", | |
| deps = [":lifecycle_example_packaged"], | |
| ) | |
| # Since `//examples/components/lifecycle/README.md` includes instructions to | |
| # use `ffx component run` to launch one of two versions of `lifecycle`, the | |
| # two versions need unique package names (`lifecycle_rust` in this case). | |
| fx_package( | |
| name = "rust", | |
| package_name = "lifecycle_rust", | |
| components = [":lifecycle-component"], | |
| ) | |
| # TODO(https://fxbug.dev/570694755): Verify whether lifecycle_manager should | |
| # use target_compatible_with (was not gated by if (is_fuchsia) in GN). | |
| rustc_binary( | |
| name = "lifecycle_manager", | |
| srcs = ["src/manager.rs"], | |
| binary_name = "lifecycle_manager_rust", | |
| crate_root = "src/manager.rs", | |
| edition = "2024", | |
| target_compatible_with = ["@platforms//os:fuchsia"], | |
| deps = [ | |
| "//examples/components/routing/fidl:echo_rust", | |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_rust", | |
| "//sdk/fidl/fuchsia.component:fuchsia.component_rust", | |
| "//src/lib/fuchsia", | |
| "//src/lib/fuchsia-component", | |
| "//third_party/rust_crates/vendor:log", | |
| ], | |
| ) | |
| fx_packaged_binary( | |
| name = "lifecycle_manager_packaged", | |
| binary = ":lifecycle_manager", | |
| binary_name = "lifecycle_manager_rust", | |
| ) | |
| fx_component_manifest( | |
| name = "manager-component_manifest", | |
| component_name = "lifecycle_manager", | |
| includes = [ | |
| "//sdk/lib/syslog:client.shard", | |
| ], | |
| manifest = "meta/manager.cml", | |
| ) | |
| fx_component( | |
| name = "manager-component", | |
| compiled_manifest = ":manager-component_manifest", | |
| visibility = ["//examples/components/lifecycle:__pkg__"], | |
| deps = [":lifecycle_manager_packaged"], | |
| ) |