| # 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"]) | |
| test_suite( | |
| name = "tests", | |
| tests = [":diagnostics-log-encoding-tests"], | |
| visibility = ["//src/lib/diagnostics:__pkg__"], | |
| ) | |
| rustc_library( | |
| name = "rust", | |
| srcs = [ | |
| "src/constants.rs", | |
| "src/encode.rs", | |
| "src/lib.rs", | |
| "src/parse.rs", | |
| ], | |
| crate_name = "diagnostics_log_encoding", | |
| edition = "2024", | |
| lint_config = "//build/config/rust/lints:clippy_warn_all", | |
| visibility = [ | |
| "//src/developer/ffx/plugins/log:__subpackages__", | |
| "//src/diagnostics/archivist:__subpackages__", | |
| "//src/diagnostics/archivist/tests/integration/realm_factory/puppet:__pkg__", | |
| "//src/diagnostics/lib/log-command:__subpackages__", | |
| "//src/diagnostics/validator/logs:__subpackages__", | |
| "//src/lib/diagnostics/fake-log-sink/rust:__subpackages__", | |
| "//src/lib/diagnostics/log:__subpackages__", | |
| "//src/starnix/kernel:__subpackages__", | |
| ], | |
| deps = [ | |
| "//sdk/fidl/fuchsia.diagnostics.types:fuchsia.diagnostics.types_rust", | |
| "//src/lib/diagnostics/log/types", | |
| "//third_party/rust_crates/vendor:bitfield", | |
| "//third_party/rust_crates/vendor:log", | |
| "//third_party/rust_crates/vendor:thiserror", | |
| "//third_party/rust_crates/vendor:zerocopy", | |
| ] + select({ | |
| "//build/bazel/platforms:is_host_os": [], | |
| "//conditions:default": ["//sdk/rust/zx"], | |
| }), | |
| ) | |
| rustc_test( | |
| name = "rust_test", | |
| crate = ":rust", | |
| # Give the generated GN `rustc_test("rust_test")` a unique `output_name`. | |
| crate_name = "diagnostics_log_encoding_lib_test", | |
| lint_config = "//build/config/rust/lints:clippy_warn_all", | |
| tags = ["manual"], | |
| target_compatible_with = ["@platforms//os:fuchsia"], | |
| deps = ["//src/lib/fuchsia"], | |
| ) | |
| fx_unittest_package( | |
| name = "diagnostics-log-encoding-tests", | |
| max_log_severity = "ERROR", | |
| unit_tests = [":rust_test"], | |
| ) |