blob: 33f43150b0bd917fec2635d3f54504aeb4c629e8 [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/cc:fx_cc_library.bzl", "fx_cc_library")
load("//build/bazel/rules/host_tests:host_rustc_test.bzl", "wrap_host_rust_test")
load("//build/bazel/rules/packages:fx_package.bzl", "fx_package")
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")
load("//build/bazel/rules/testing:fx_unittest_component.bzl", "fx_unittest_component")
package(default_applicable_licenses = ["//:license"])
test_suite(
name = "tests",
tests = [
":kstring-cpp-integration-test",
":kstring-test",
],
visibility = ["//src/lib:__pkg__"],
)
test_suite(
name = "host_tests",
tests = [":kstring_host_test"],
visibility = ["//src/lib:__pkg__"],
)
rustc_library(
name = "kstring",
srcs = [
"src/interned_category.rs",
"src/interned_string.rs",
"src/lib.rs",
],
edition = "2024",
proc_macro_deps = ["//src/lib/kstring/macro:kstring-macro"],
visibility = [
"//src/lib/ksync:__pkg__",
"//src/lib/lockdep/rust:__pkg__",
"//zircon/kernel:__subpackages__",
],
)
rustc_test(
name = "kstring_test",
crate = ":kstring",
tags = ["manual"],
)
wrap_host_rust_test(
name = "kstring_host_test",
binary_name = "kstring_test",
)
fx_unittest_component(
name = "kstring-test-component",
binary = ":kstring_test",
component_name = "kstring-test",
)
fx_package(
name = "kstring-test-package",
package_name = "kstring-test",
test_components = [":kstring-test-component"],
)
fx_test(
name = "kstring-test",
environments = ["//build/testing/environments:emu_env"],
package = ":kstring-test-package",
)
# TODO(https://fxbug.dev/570694755): Verify whether cpp_test_lib should use target_compatible_with
# (was not gated by if (is_fuchsia) in GN, but //src/performance/lib/fxt includes Fuchsia-only
# <zircon/assert.h>).
fx_cc_library(
name = "cpp_test_lib",
testonly = True,
srcs = ["tests/cpp_interned.cc"],
target_compatible_with = ["@platforms//os:fuchsia"],
deps = ["//src/performance/lib/fxt"],
alwayslink = True,
)
# cpp_test_lib is C++, so GN targets linking it with rustc need
# //build/config/fuchsia:dynamic_cpp_standard_library; Bazel's C++ toolchain
# links libc++ automatically via link_deps.
# @bazel2gn:raw_attribute:configs += [ "//build/config/fuchsia:dynamic_cpp_standard_library" ]
rustc_test(
name = "kstring_cpp_integration_test",
srcs = ["tests/integration_test.rs"],
crate_root = "tests/integration_test.rs",
edition = "2024",
link_deps = [":cpp_test_lib"],
tags = ["manual"],
target_compatible_with = ["@platforms//os:fuchsia"],
deps = [":kstring"],
)
fx_unittest_component(
name = "kstring-cpp-integration-test-component",
binary = ":kstring_cpp_integration_test",
component_name = "kstring-cpp-integration-test",
)
fx_package(
name = "kstring-cpp-integration-test-package",
package_name = "kstring-cpp-integration-test",
test_components = [":kstring-cpp-integration-test-component"],
)
fx_test(
name = "kstring-cpp-integration-test",
environments = ["//build/testing/environments:emu_env"],
package = ":kstring-cpp-integration-test-package",
)