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_proc_macro( 19 name = "pw_tokenizer_macro", 20 srcs = [ 21 "pw_tokenizer_macro.rs", 22 ], 23 visibility = ["//visibility:public"], 24 deps = [ 25 ":pw_tokenizer_core", 26 "//pw_format/rust:pw_format", 27 "//pw_status/rust:pw_status", 28 "@rust_crates//:proc-macro2", 29 "@rust_crates//:quote", 30 "@rust_crates//:syn", 31 ], 32) 33 34rust_test( 35 name = "pw_tokenizer_macro_test", 36 crate = ":pw_tokenizer_macro", 37 # TODO: b/343726867 - support on-device rust tests 38 target_compatible_with = incompatible_with_mcu(), 39) 40 41rust_library( 42 name = "pw_tokenizer_core", 43 srcs = [ 44 "pw_tokenizer_core.rs", 45 "pw_tokenizer_core_test_cases.rs", 46 ], 47 crate_features = select({ 48 "@rust_crates//:std": ["std"], 49 "//conditions:default": [""], 50 }), 51 visibility = ["//visibility:public"], 52) 53 54rust_test( 55 name = "pw_tokenizer_core_test", 56 crate = ":pw_tokenizer_core", 57 crate_features = select({ 58 "@rust_crates//:std": ["std"], 59 "//conditions:default": [""], 60 }), 61 # TODO: b/343726867 - support on-device rust tests 62 target_compatible_with = incompatible_with_mcu(), 63) 64 65rust_doc_test( 66 name = "pw_tokenizer_core_doc_test", 67 crate = ":pw_tokenizer_core", 68 target_compatible_with = incompatible_with_mcu(), 69) 70 71rust_doc( 72 name = "pw_tokenizer_core_doc", 73 crate = ":pw_tokenizer_core", 74 target_compatible_with = incompatible_with_mcu(), 75) 76 77rust_library( 78 name = "pw_tokenizer", 79 srcs = [ 80 "pw_tokenizer/internal.rs", 81 "pw_tokenizer/lib.rs", 82 ], 83 crate_features = select({ 84 "@rust_crates//:std": ["std"], 85 "//conditions:default": [""], 86 }), 87 proc_macro_deps = [":pw_tokenizer_macro"], 88 visibility = ["//visibility:public"], 89 deps = [ 90 ":pw_tokenizer_core", 91 "//pw_bytes/rust:pw_bytes", 92 "//pw_format/rust:pw_format_core", 93 "//pw_status/rust:pw_status", 94 "//pw_stream/rust:pw_stream", 95 "//pw_varint/rust:pw_varint", 96 ] + select({ 97 "@rust_crates//:std": [ 98 "//pw_format/rust:pw_format", # Added for rustdoc linking support. 99 ], 100 "//conditions:default": [], 101 }), 102) 103 104rust_test( 105 name = "pw_tokenizer_test", 106 crate = ":pw_tokenizer", 107 crate_features = select({ 108 "@rust_crates//:std": ["std"], 109 "//conditions:default": [""], 110 }), 111 # TODO: b/343726867 - support on-device rust tests 112 target_compatible_with = incompatible_with_mcu(), 113) 114 115rust_doc_test( 116 name = "pw_tokenizer_doc_test", 117 crate = ":pw_tokenizer", 118 target_compatible_with = incompatible_with_mcu(), 119) 120 121rust_doc( 122 name = "pw_tokenizer_doc", 123 crate = ":pw_tokenizer", 124 target_compatible_with = incompatible_with_mcu(), 125) 126