| # 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/host_tests:host_rustc_test.bzl", "wrap_host_rust_test") | |
| 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 = [":kalloc-rust-test-pkg"], | |
| visibility = ["//src/lib:__pkg__"], | |
| ) | |
| test_suite( | |
| name = "host_tests", | |
| target_compatible_with = HOST_OS_CONSTRAINTS, | |
| tests = [":kalloc_host_test"], | |
| visibility = ["//src/lib:__pkg__"], | |
| ) | |
| # TODO(https://fxbug.dev/570694755): The kernel build is not yet supported in | |
| # Bazel, so the kernel-only rustflags are emitted in GN via raw_attribute. | |
| # @bazel2gn:raw_attribute:if (is_kernel) { rustflags = [ "--cfg=is_kernel" ] } | |
| rustc_library( | |
| name = "kalloc", | |
| srcs = [ | |
| "src/allocator.rs", | |
| "src/boxed.rs", | |
| "src/lib.rs", | |
| ], | |
| edition = "2024", | |
| visibility = [ | |
| "//zircon/kernel:__subpackages__", | |
| "//zircon/system:__subpackages__", | |
| ], | |
| deps = [ | |
| "//sdk/rust/zx-status", | |
| "//third_party/rust_crates/vendor:pin-init", | |
| "//third_party/rust_crates/vendor:zerocopy", | |
| ], | |
| ) | |
| rustc_test( | |
| name = "kalloc_test", | |
| crate = ":kalloc", | |
| ) | |
| wrap_host_rust_test( | |
| name = "kalloc_host_test", | |
| binary_name = "kalloc_test", | |
| ) | |
| fx_unittest_package( | |
| name = "kalloc-rust-test-pkg", | |
| package_name = "kalloc-rust-test", | |
| unit_tests = [":kalloc_test"], | |
| ) |