fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

scentiniDon't propagate `compatible_with` to the underlying `cargo_build_script` `rust_binary` target (#1754)941c7cca

rust-analyzer
1.4 KiB68 linesraw
1"""Tests for the cargo_build_script rule"""
2
3load("@bazel_skylib//rules:write_file.bzl", "write_file")
4load("//cargo:defs.bzl", "cargo_build_script")
5load("//rust:defs.bzl", "rust_library", "rust_test")
6
7# Test that tools are built in the exec configuration.
8cargo_build_script(
9    name = "tools_exec_build_rs",
10    srcs = ["build.rs"],
11    build_script_env = {"TOOL": "$(execpath :tool)"},
12    edition = "2018",
13    # Add a flag to test that they're exposed to the build script
14    rustc_flags = ["--verbose"],
15    tools = [":tool"],
16)
17
18write_file(
19    name = "tool",
20    out = "tool-file",
21    content = [""],
22)
23
24rust_test(
25    name = "tools_exec",
26    srcs = ["tools_exec.rs"],
27    edition = "2018",
28    deps = [":tools_exec_build_rs"],
29)
30
31environment_group(
32    name = "foo_environment",
33    defaults = [":foo"],
34    environments = [
35        ":foo",
36        ":bar",
37    ],
38)
39
40environment(
41    name = "foo",
42)
43
44environment(
45    name = "bar",
46)
47
48rust_library(
49    name = "build_script_dep_without_compatible_with",
50    srcs = ["lib.rs"],
51    edition = "2018",
52)
53
54cargo_build_script(
55    name = "empty_build_script",
56    srcs = ["do_nothing.rs"],
57    compatible_with = [":bar"],
58    edition = "2018",
59    deps = [":build_script_dep_without_compatible_with"],
60)
61
62rust_test(
63    name = "test_compatible_with",
64    srcs = ["lib.rs"],
65    compatible_with = [":bar"],
66    edition = "2018",
67    deps = [":empty_build_script"],
68)