1*61c4878aSAndroid Build Coastguard Worker# Copyright 2023 The Pigweed Authors 2*61c4878aSAndroid Build Coastguard Worker# 3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of 5*61c4878aSAndroid Build Coastguard Worker# the License at 6*61c4878aSAndroid Build Coastguard Worker# 7*61c4878aSAndroid Build Coastguard Worker# https://www.apache.org/licenses/LICENSE-2.0 8*61c4878aSAndroid Build Coastguard Worker# 9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under 13*61c4878aSAndroid Build Coastguard Worker# the License. 14*61c4878aSAndroid Build Coastguard Worker 15*61c4878aSAndroid Build Coastguard Workerload("@rules_rust//rust:defs.bzl", "rust_doc", "rust_doc_test", "rust_library", "rust_proc_macro", "rust_test") 16*61c4878aSAndroid Build Coastguard Workerload("//pw_build:compatibility.bzl", "incompatible_with_mcu") 17*61c4878aSAndroid Build Coastguard Worker 18*61c4878aSAndroid Build Coastguard Workerrust_proc_macro( 19*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_macro", 20*61c4878aSAndroid Build Coastguard Worker srcs = [ 21*61c4878aSAndroid Build Coastguard Worker "pw_tokenizer_macro.rs", 22*61c4878aSAndroid Build Coastguard Worker ], 23*61c4878aSAndroid Build Coastguard Worker visibility = ["//visibility:public"], 24*61c4878aSAndroid Build Coastguard Worker deps = [ 25*61c4878aSAndroid Build Coastguard Worker ":pw_tokenizer_core", 26*61c4878aSAndroid Build Coastguard Worker "//pw_format/rust:pw_format", 27*61c4878aSAndroid Build Coastguard Worker "//pw_status/rust:pw_status", 28*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:proc-macro2", 29*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:quote", 30*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:syn", 31*61c4878aSAndroid Build Coastguard Worker ], 32*61c4878aSAndroid Build Coastguard Worker) 33*61c4878aSAndroid Build Coastguard Worker 34*61c4878aSAndroid Build Coastguard Workerrust_test( 35*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_macro_test", 36*61c4878aSAndroid Build Coastguard Worker crate = ":pw_tokenizer_macro", 37*61c4878aSAndroid Build Coastguard Worker # TODO: b/343726867 - support on-device rust tests 38*61c4878aSAndroid Build Coastguard Worker target_compatible_with = incompatible_with_mcu(), 39*61c4878aSAndroid Build Coastguard Worker) 40*61c4878aSAndroid Build Coastguard Worker 41*61c4878aSAndroid Build Coastguard Workerrust_library( 42*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_core", 43*61c4878aSAndroid Build Coastguard Worker srcs = [ 44*61c4878aSAndroid Build Coastguard Worker "pw_tokenizer_core.rs", 45*61c4878aSAndroid Build Coastguard Worker "pw_tokenizer_core_test_cases.rs", 46*61c4878aSAndroid Build Coastguard Worker ], 47*61c4878aSAndroid Build Coastguard Worker crate_features = select({ 48*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:std": ["std"], 49*61c4878aSAndroid Build Coastguard Worker "//conditions:default": [""], 50*61c4878aSAndroid Build Coastguard Worker }), 51*61c4878aSAndroid Build Coastguard Worker visibility = ["//visibility:public"], 52*61c4878aSAndroid Build Coastguard Worker) 53*61c4878aSAndroid Build Coastguard Worker 54*61c4878aSAndroid Build Coastguard Workerrust_test( 55*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_core_test", 56*61c4878aSAndroid Build Coastguard Worker crate = ":pw_tokenizer_core", 57*61c4878aSAndroid Build Coastguard Worker crate_features = select({ 58*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:std": ["std"], 59*61c4878aSAndroid Build Coastguard Worker "//conditions:default": [""], 60*61c4878aSAndroid Build Coastguard Worker }), 61*61c4878aSAndroid Build Coastguard Worker # TODO: b/343726867 - support on-device rust tests 62*61c4878aSAndroid Build Coastguard Worker target_compatible_with = incompatible_with_mcu(), 63*61c4878aSAndroid Build Coastguard Worker) 64*61c4878aSAndroid Build Coastguard Worker 65*61c4878aSAndroid Build Coastguard Workerrust_doc_test( 66*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_core_doc_test", 67*61c4878aSAndroid Build Coastguard Worker crate = ":pw_tokenizer_core", 68*61c4878aSAndroid Build Coastguard Worker target_compatible_with = incompatible_with_mcu(), 69*61c4878aSAndroid Build Coastguard Worker) 70*61c4878aSAndroid Build Coastguard Worker 71*61c4878aSAndroid Build Coastguard Workerrust_doc( 72*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_core_doc", 73*61c4878aSAndroid Build Coastguard Worker crate = ":pw_tokenizer_core", 74*61c4878aSAndroid Build Coastguard Worker target_compatible_with = incompatible_with_mcu(), 75*61c4878aSAndroid Build Coastguard Worker) 76*61c4878aSAndroid Build Coastguard Worker 77*61c4878aSAndroid Build Coastguard Workerrust_library( 78*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer", 79*61c4878aSAndroid Build Coastguard Worker srcs = [ 80*61c4878aSAndroid Build Coastguard Worker "pw_tokenizer/internal.rs", 81*61c4878aSAndroid Build Coastguard Worker "pw_tokenizer/lib.rs", 82*61c4878aSAndroid Build Coastguard Worker ], 83*61c4878aSAndroid Build Coastguard Worker crate_features = select({ 84*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:std": ["std"], 85*61c4878aSAndroid Build Coastguard Worker "//conditions:default": [""], 86*61c4878aSAndroid Build Coastguard Worker }), 87*61c4878aSAndroid Build Coastguard Worker proc_macro_deps = [":pw_tokenizer_macro"], 88*61c4878aSAndroid Build Coastguard Worker visibility = ["//visibility:public"], 89*61c4878aSAndroid Build Coastguard Worker deps = [ 90*61c4878aSAndroid Build Coastguard Worker ":pw_tokenizer_core", 91*61c4878aSAndroid Build Coastguard Worker "//pw_bytes/rust:pw_bytes", 92*61c4878aSAndroid Build Coastguard Worker "//pw_format/rust:pw_format_core", 93*61c4878aSAndroid Build Coastguard Worker "//pw_status/rust:pw_status", 94*61c4878aSAndroid Build Coastguard Worker "//pw_stream/rust:pw_stream", 95*61c4878aSAndroid Build Coastguard Worker "//pw_varint/rust:pw_varint", 96*61c4878aSAndroid Build Coastguard Worker ] + select({ 97*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:std": [ 98*61c4878aSAndroid Build Coastguard Worker "//pw_format/rust:pw_format", # Added for rustdoc linking support. 99*61c4878aSAndroid Build Coastguard Worker ], 100*61c4878aSAndroid Build Coastguard Worker "//conditions:default": [], 101*61c4878aSAndroid Build Coastguard Worker }), 102*61c4878aSAndroid Build Coastguard Worker) 103*61c4878aSAndroid Build Coastguard Worker 104*61c4878aSAndroid Build Coastguard Workerrust_test( 105*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_test", 106*61c4878aSAndroid Build Coastguard Worker crate = ":pw_tokenizer", 107*61c4878aSAndroid Build Coastguard Worker crate_features = select({ 108*61c4878aSAndroid Build Coastguard Worker "@rust_crates//:std": ["std"], 109*61c4878aSAndroid Build Coastguard Worker "//conditions:default": [""], 110*61c4878aSAndroid Build Coastguard Worker }), 111*61c4878aSAndroid Build Coastguard Worker # TODO: b/343726867 - support on-device rust tests 112*61c4878aSAndroid Build Coastguard Worker target_compatible_with = incompatible_with_mcu(), 113*61c4878aSAndroid Build Coastguard Worker) 114*61c4878aSAndroid Build Coastguard Worker 115*61c4878aSAndroid Build Coastguard Workerrust_doc_test( 116*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_doc_test", 117*61c4878aSAndroid Build Coastguard Worker crate = ":pw_tokenizer", 118*61c4878aSAndroid Build Coastguard Worker target_compatible_with = incompatible_with_mcu(), 119*61c4878aSAndroid Build Coastguard Worker) 120*61c4878aSAndroid Build Coastguard Worker 121*61c4878aSAndroid Build Coastguard Workerrust_doc( 122*61c4878aSAndroid Build Coastguard Worker name = "pw_tokenizer_doc", 123*61c4878aSAndroid Build Coastguard Worker crate = ":pw_tokenizer", 124*61c4878aSAndroid Build Coastguard Worker target_compatible_with = incompatible_with_mcu(), 125*61c4878aSAndroid Build Coastguard Worker) 126