xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/per_platform_printer/BUILD.bazel (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
2
3package(default_visibility = ["//visibility:public"])
4
5rust_binary(
6    name = "print",
7    srcs = ["main.rs"],
8    deps = [
9        ":printer",
10    ],
11)
12
13rust_library(
14    name = "printer",
15    srcs = [
16        "lib.rs",
17        "print_generic.rs",
18    ] + select({
19        "@rules_rust//rust/platform:linux": [
20            ":print_linux.rs",
21        ],
22        "@rules_rust//rust/platform:macos": [
23            ":print_macos.rs",
24        ],
25        "@rules_rust//rust/platform:windows": [
26            ":print_windows.rs",
27        ],
28    }),
29    # Because each os specific file is conditionally added to the target,
30    # rustfmt does not have all sources to complete formatting. To avoid
31    # this failure, rustfmt is not run on this target
32    tags = ["norustfmt"],
33)
34
35rust_test(
36    name = "printer_test",
37    crate = ":printer",
38    # The same rational used for `printer` applies here. Do not run rustfmt
39    # since not all sources are available.
40    tags = ["norustfmt"],
41)
42