| # 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_library", "rust_proc_macro") |
| |
| rust_library( |
| name = "console", |
| srcs = ["console.rs"], |
| deps = [ |
| "//lib/pw_status", |
| "@rust_crates//:embedded-io", |
| ], |
| ) |
| |
| rust_library( |
| name = "console_backend_stdio", |
| srcs = ["console_backend_stdio.rs"], |
| crate_name = "console_backend", |
| target_compatible_with = incompatible_with_mcu(), |
| deps = [ |
| "//lib/pw_status", |
| ], |
| ) |
| |
| rust_library( |
| name = "console_backend_semihosting", |
| srcs = ["console_backend_semihosting.rs"], |
| crate_name = "console_backend", |
| target_compatible_with = select({ |
| "@pigweed//pw_build/constraints/arm:cortex-m0": [], |
| "@pigweed//pw_build/constraints/arm:cortex-m3": [], |
| "@pigweed//pw_build/constraints/arm:cortex-m33": [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| }), |
| deps = [ |
| "//lib/pw_status", |
| "@rust_crates//:cortex-m-semihosting", |
| "@rust_crates//:embedded-io", |
| ], |
| ) |
| |
| label_flag( |
| name = "console_backend", |
| build_setting_default = ":console_backend_stdio", |
| visibility = ["//visibility:public"], |
| ) |
| |
| rust_proc_macro( |
| name = "pw_log_backend_macro", |
| srcs = [ |
| "pw_log_backend_macro.rs", |
| ], |
| visibility = ["//visibility:public"], |
| deps = [ |
| "@pigweed//pw_format/rust:pw_format", |
| "@pigweed//pw_log/rust:pw_log_backend_api", |
| "@pigweed//pw_status/rust:pw_status", |
| "@rust_crates//:proc-macro2", |
| "@rust_crates//:quote", |
| "@rust_crates//:syn", |
| ], |
| ) |
| |
| rust_library( |
| name = "pw_log_backend", |
| srcs = [ |
| "pw_log_backend.rs", |
| ], |
| crate_name = "pw_log_backend", |
| proc_macro_deps = [":pw_log_backend_macro"], |
| tags = ["manual"], |
| visibility = ["//visibility:public"], |
| deps = [ |
| ":console", |
| "@pigweed//pw_log/rust:pw_log_backend_api", |
| "@rust_crates//:embedded-io", |
| ], |
| ) |