xref: /aosp_15_r20/external/pigweed/pw_format/rust/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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_library(
19*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_core",
20*61c4878aSAndroid Build Coastguard Worker    srcs = [
21*61c4878aSAndroid Build Coastguard Worker        "pw_format_core.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_status/rust:pw_status",
26*61c4878aSAndroid Build Coastguard Worker    ],
27*61c4878aSAndroid Build Coastguard Worker)
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Workerrust_library(
30*61c4878aSAndroid Build Coastguard Worker    name = "pw_format",
31*61c4878aSAndroid Build Coastguard Worker    srcs = [
32*61c4878aSAndroid Build Coastguard Worker        "pw_format/core_fmt.rs",
33*61c4878aSAndroid Build Coastguard Worker        "pw_format/lib.rs",
34*61c4878aSAndroid Build Coastguard Worker        "pw_format/macros.rs",
35*61c4878aSAndroid Build Coastguard Worker        "pw_format/printf.rs",
36*61c4878aSAndroid Build Coastguard Worker        "pw_format/tests/core_fmt.rs",
37*61c4878aSAndroid Build Coastguard Worker        "pw_format/tests/mod.rs",
38*61c4878aSAndroid Build Coastguard Worker        "pw_format/tests/printf.rs",
39*61c4878aSAndroid Build Coastguard Worker    ],
40*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:public"],
41*61c4878aSAndroid Build Coastguard Worker    deps = [
42*61c4878aSAndroid Build Coastguard Worker        ":pw_format_core",
43*61c4878aSAndroid Build Coastguard Worker        "//pw_status/rust:pw_status",
44*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:nom",
45*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:proc-macro2",
46*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:quote",
47*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:syn",
48*61c4878aSAndroid Build Coastguard Worker    ],
49*61c4878aSAndroid Build Coastguard Worker)
50*61c4878aSAndroid Build Coastguard Worker
51*61c4878aSAndroid Build Coastguard Workerrust_test(
52*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_test",
53*61c4878aSAndroid Build Coastguard Worker    crate = ":pw_format",
54*61c4878aSAndroid Build Coastguard Worker    # TODO: b/343726867 - support on-device rust tests
55*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
56*61c4878aSAndroid Build Coastguard Worker)
57*61c4878aSAndroid Build Coastguard Worker
58*61c4878aSAndroid Build Coastguard Workerrust_doc_test(
59*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_doc_test",
60*61c4878aSAndroid Build Coastguard Worker    crate = ":pw_format",
61*61c4878aSAndroid Build Coastguard Worker    deps = ["//pw_bytes/rust:pw_bytes"],
62*61c4878aSAndroid Build Coastguard Worker)
63*61c4878aSAndroid Build Coastguard Worker
64*61c4878aSAndroid Build Coastguard Workerrust_doc(
65*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_doc",
66*61c4878aSAndroid Build Coastguard Worker    crate = ":pw_format",
67*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
68*61c4878aSAndroid Build Coastguard Worker)
69*61c4878aSAndroid Build Coastguard Worker
70*61c4878aSAndroid Build Coastguard Workerrust_proc_macro(
71*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_example_macro",
72*61c4878aSAndroid Build Coastguard Worker    srcs = [
73*61c4878aSAndroid Build Coastguard Worker        "pw_format_example_macro.rs",
74*61c4878aSAndroid Build Coastguard Worker    ],
75*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:public"],
76*61c4878aSAndroid Build Coastguard Worker    deps = [
77*61c4878aSAndroid Build Coastguard Worker        ":pw_format",
78*61c4878aSAndroid Build Coastguard Worker        "//pw_status/rust:pw_status",
79*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:proc-macro2",
80*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:quote",
81*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:syn",
82*61c4878aSAndroid Build Coastguard Worker    ],
83*61c4878aSAndroid Build Coastguard Worker)
84*61c4878aSAndroid Build Coastguard Worker
85*61c4878aSAndroid Build Coastguard Workerrust_library(
86*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_example_macro_test",
87*61c4878aSAndroid Build Coastguard Worker    srcs = [
88*61c4878aSAndroid Build Coastguard Worker        "pw_format_example_macro_test.rs",
89*61c4878aSAndroid Build Coastguard Worker    ],
90*61c4878aSAndroid Build Coastguard Worker    proc_macro_deps = [
91*61c4878aSAndroid Build Coastguard Worker        ":pw_format_example_macro",
92*61c4878aSAndroid Build Coastguard Worker    ],
93*61c4878aSAndroid Build Coastguard Worker    tags = ["manual"],
94*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:public"],
95*61c4878aSAndroid Build Coastguard Worker)
96*61c4878aSAndroid Build Coastguard Worker
97*61c4878aSAndroid Build Coastguard Workerrust_test(
98*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_example_macro_test_test",
99*61c4878aSAndroid Build Coastguard Worker    crate = ":pw_format_example_macro_test",
100*61c4878aSAndroid Build Coastguard Worker    # TODO: b/343726867 - support on-device rust tests
101*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
102*61c4878aSAndroid Build Coastguard Worker)
103*61c4878aSAndroid Build Coastguard Worker
104*61c4878aSAndroid Build Coastguard Workerrust_proc_macro(
105*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_test_macros",
106*61c4878aSAndroid Build Coastguard Worker    srcs = [
107*61c4878aSAndroid Build Coastguard Worker        "pw_format_test_macros.rs",
108*61c4878aSAndroid Build Coastguard Worker    ],
109*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:public"],
110*61c4878aSAndroid Build Coastguard Worker    deps = [
111*61c4878aSAndroid Build Coastguard Worker        ":pw_format",
112*61c4878aSAndroid Build Coastguard Worker        "//pw_status/rust:pw_status",
113*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:proc-macro2",
114*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:quote",
115*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:syn",
116*61c4878aSAndroid Build Coastguard Worker    ],
117*61c4878aSAndroid Build Coastguard Worker)
118*61c4878aSAndroid Build Coastguard Worker
119*61c4878aSAndroid Build Coastguard Workerrust_library(
120*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_test_macros_printf_test",
121*61c4878aSAndroid Build Coastguard Worker    srcs = [
122*61c4878aSAndroid Build Coastguard Worker        "pw_format_test_macros_printf_test.rs",
123*61c4878aSAndroid Build Coastguard Worker    ],
124*61c4878aSAndroid Build Coastguard Worker    proc_macro_deps = [
125*61c4878aSAndroid Build Coastguard Worker        ":pw_format_test_macros",
126*61c4878aSAndroid Build Coastguard Worker    ],
127*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:public"],
128*61c4878aSAndroid Build Coastguard Worker    deps = [
129*61c4878aSAndroid Build Coastguard Worker        ":pw_format",
130*61c4878aSAndroid Build Coastguard Worker        ":pw_format_core",
131*61c4878aSAndroid Build Coastguard Worker        "//pw_bytes/rust:pw_bytes",
132*61c4878aSAndroid Build Coastguard Worker    ],
133*61c4878aSAndroid Build Coastguard Worker)
134*61c4878aSAndroid Build Coastguard Worker
135*61c4878aSAndroid Build Coastguard Workerrust_test(
136*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_test_macros_printf_test_test",
137*61c4878aSAndroid Build Coastguard Worker    crate = ":pw_format_test_macros_printf_test",
138*61c4878aSAndroid Build Coastguard Worker    # TODO: b/343726867 - support on-device rust tests
139*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
140*61c4878aSAndroid Build Coastguard Worker)
141*61c4878aSAndroid Build Coastguard Worker
142*61c4878aSAndroid Build Coastguard Workerrust_library(
143*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_test_macros_core_fmt_test",
144*61c4878aSAndroid Build Coastguard Worker    srcs = [
145*61c4878aSAndroid Build Coastguard Worker        "pw_format_test_macros_core_fmt_test.rs",
146*61c4878aSAndroid Build Coastguard Worker    ],
147*61c4878aSAndroid Build Coastguard Worker    proc_macro_deps = [
148*61c4878aSAndroid Build Coastguard Worker        ":pw_format_test_macros",
149*61c4878aSAndroid Build Coastguard Worker    ],
150*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:public"],
151*61c4878aSAndroid Build Coastguard Worker    deps = [
152*61c4878aSAndroid Build Coastguard Worker        ":pw_format",
153*61c4878aSAndroid Build Coastguard Worker        ":pw_format_core",
154*61c4878aSAndroid Build Coastguard Worker        "//pw_bytes/rust:pw_bytes",
155*61c4878aSAndroid Build Coastguard Worker    ],
156*61c4878aSAndroid Build Coastguard Worker)
157*61c4878aSAndroid Build Coastguard Worker
158*61c4878aSAndroid Build Coastguard Workerrust_test(
159*61c4878aSAndroid Build Coastguard Worker    name = "pw_format_test_macros_core_fmt_test_test",
160*61c4878aSAndroid Build Coastguard Worker    crate = ":pw_format_test_macros_core_fmt_test",
161*61c4878aSAndroid Build Coastguard Worker    # TODO: b/343726867 - support on-device rust tests
162*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
163*61c4878aSAndroid Build Coastguard Worker)
164