# Copyright 2025 The Pigweed Authors # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. load("@pigweed//pw_build:compatibility.bzl", "incompatible_with_mcu") load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test") load("//pw_build:merge_flags.bzl", "flags_from_dict") load("//pw_kernel:flags.bzl", "KERNEL_COMMON_FLAGS") COMMON_DEPS = [ "//pw_kernel/arch/host:arch_host", "//pw_kernel/kernel", "//pw_kernel/subsys/console:console_backend", ] platform( name = "host", flags = flags_from_dict( KERNEL_COMMON_FLAGS | { "//pw_kernel/config:kernel_config": ":config", "//pw_kernel/subsys/console:console_backend": "//pw_kernel/subsys/console:console_backend_stdio", # For simplicity have the host use basic logger rather than tokenized logger. "//pw_log/rust:pw_log_backend": "//pw_kernel/subsys/console:pw_log_backend_basic", }, ), parents = ["@bazel_tools//tools:host_platform"], visibility = ["//visibility:private"], ) platform( name = "doctest", flags = flags_from_dict( KERNEL_COMMON_FLAGS | { "//pw_kernel/config:kernel_config": ":config", # Activate the default panic handler so rustdoc tests don't need to register one. "//pw_kernel/lib/pw_assert:default_handler": "true", # Use the println backend To avoid pulling in the implicit console dep. "//pw_log/rust:pw_log_backend": "@pigweed//pw_log/rust:pw_log_backend_println", }, ), parents = ["@bazel_tools//tools:host_platform"], visibility = ["//visibility:private"], ) rust_binary( name = "target", srcs = ["target.rs"], tags = ["kernel"], target_compatible_with = incompatible_with_mcu(), deps = COMMON_DEPS, ) rust_test( name = "unittest_runner", srcs = ["target.rs"], tags = ["kernel"], target_compatible_with = incompatible_with_mcu(), use_libtest_harness = False, deps = COMMON_DEPS + [ "//pw_kernel/lib/unittest:unittest_core", "//pw_log/rust:pw_log", ], ) rust_library( name = "config", srcs = ["config.rs"], crate_name = "kernel_config", tags = ["kernel"], target_compatible_with = incompatible_with_mcu(), deps = [ "//pw_kernel/config:kernel_config_interface", ], )