1# Copyright 2023 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_doc_test", "rust_library", "rust_proc_macro", "rust_test") 16load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 17 18rust_library( 19 name = "pw_format_core", 20 srcs = [ 21 "pw_format_core.rs", 22 ], 23 visibility = ["//visibility:public"], 24 deps = [ 25 "//pw_status/rust:pw_status", 26 ], 27) 28 29rust_library( 30 name = "pw_format", 31 srcs = [ 32 "pw_format/core_fmt.rs", 33 "pw_format/lib.rs", 34 "pw_format/macros.rs", 35 "pw_format/printf.rs", 36 "pw_format/tests/core_fmt.rs", 37 "pw_format/tests/mod.rs", 38 "pw_format/tests/printf.rs", 39 ], 40 crate_features = select({ 41 "@rules_rust//rust/toolchain/channel:nightly": ["nightly_tait"], 42 "//conditions:default": [], 43 }), 44 visibility = ["//visibility:public"], 45 deps = [ 46 ":pw_format_core", 47 "//pw_status/rust:pw_status", 48 "@rust_crates//:nom", 49 "@rust_crates//:proc-macro2", 50 "@rust_crates//:quote", 51 "@rust_crates//:syn", 52 ], 53) 54 55rust_test( 56 name = "pw_format_test", 57 crate = ":pw_format", 58 crate_features = select({ 59 "@rules_rust//rust/toolchain/channel:nightly": ["nightly"], 60 "//conditions:default": [], 61 }), 62 # TODO: b/343726867 - support on-device rust tests 63 target_compatible_with = incompatible_with_mcu(), 64) 65 66rust_doc_test( 67 name = "pw_format_doc_test", 68 crate = ":pw_format", 69 deps = ["//pw_bytes/rust:pw_bytes"], 70) 71 72rust_doc( 73 name = "pw_format_doc", 74 crate = ":pw_format", 75 target_compatible_with = incompatible_with_mcu(), 76) 77 78rust_proc_macro( 79 name = "pw_format_example_macro", 80 srcs = [ 81 "pw_format_example_macro.rs", 82 ], 83 visibility = ["//visibility:public"], 84 deps = [ 85 ":pw_format", 86 "//pw_status/rust:pw_status", 87 "@rust_crates//:proc-macro2", 88 "@rust_crates//:quote", 89 "@rust_crates//:syn", 90 ], 91) 92 93rust_library( 94 name = "pw_format_example_macro_test", 95 srcs = [ 96 "pw_format_example_macro_test.rs", 97 ], 98 proc_macro_deps = [ 99 ":pw_format_example_macro", 100 ], 101 tags = ["manual"], 102 visibility = ["//visibility:public"], 103) 104 105rust_test( 106 name = "pw_format_example_macro_test_test", 107 crate = ":pw_format_example_macro_test", 108 crate_features = select({ 109 "@rules_rust//rust/toolchain/channel:nightly": ["nightly"], 110 "//conditions:default": [], 111 }), 112 # TODO: b/343726867 - support on-device rust tests 113 target_compatible_with = incompatible_with_mcu(), 114) 115 116rust_proc_macro( 117 name = "pw_format_test_macros", 118 srcs = [ 119 "pw_format_test_macros.rs", 120 ], 121 visibility = ["//visibility:public"], 122 deps = [ 123 ":pw_format", 124 "//pw_status/rust:pw_status", 125 "@rust_crates//:proc-macro2", 126 "@rust_crates//:quote", 127 "@rust_crates//:syn", 128 ], 129) 130 131rust_library( 132 name = "pw_format_test_macros_printf_test", 133 srcs = [ 134 "pw_format_test_macros_printf_test.rs", 135 ], 136 proc_macro_deps = [ 137 ":pw_format_test_macros", 138 ], 139 visibility = ["//visibility:public"], 140 deps = [ 141 ":pw_format", 142 ":pw_format_core", 143 "//pw_bytes/rust:pw_bytes", 144 ], 145) 146 147rust_test( 148 name = "pw_format_test_macros_printf_test_test", 149 crate = ":pw_format_test_macros_printf_test", 150 # TODO: b/343726867 - support on-device rust tests 151 crate_features = select({ 152 "@rules_rust//rust/toolchain/channel:nightly": ["nightly"], 153 "//conditions:default": [], 154 }), 155 target_compatible_with = incompatible_with_mcu(), 156) 157 158rust_library( 159 name = "pw_format_test_macros_core_fmt_test", 160 srcs = [ 161 "pw_format_test_macros_core_fmt_test.rs", 162 ], 163 proc_macro_deps = [ 164 ":pw_format_test_macros", 165 ], 166 visibility = ["//visibility:public"], 167 deps = [ 168 ":pw_format", 169 ":pw_format_core", 170 "//pw_bytes/rust:pw_bytes", 171 ], 172) 173 174rust_test( 175 name = "pw_format_test_macros_core_fmt_test_test", 176 crate = ":pw_format_test_macros_core_fmt_test", 177 crate_features = select({ 178 "@rules_rust//rust/toolchain/channel:nightly": ["nightly"], 179 "//conditions:default": [], 180 }), 181 # TODO: b/343726867 - support on-device rust tests 182 target_compatible_with = incompatible_with_mcu(), 183) 184