fork/rules_rust

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

Daniel Wagner-HallMake toolchain vars available but don't automatically set them (#2969)4e593b6c

cleanup
1.1 KiB36 linesraw
1load("@bazel_skylib//rules:write_file.bzl", "write_file")
2load("//cargo:defs.bzl", "cargo_build_script")
3load("//rust:defs.bzl", "rust_test")
4
5# Test that tools are built in the exec configuration.
6cargo_build_script(
7    name = "tools_exec_build_rs",
8    srcs = ["build.rs"],
9    build_script_env = {
10        # Note that cargo_build_script working directories are not
11        # guaranteed to be the execroot. Thus, the expanded value
12        # is resolved to an absolute path with the help of it's
13        # process wrapper resolving `${pwd}`.
14        "EXPANDED_TOOLCHAIN_VAR": "$${pwd}/$(RUSTC)",
15        "TOOL": "$(execpath :tool)",
16    },
17    edition = "2018",
18    links = "beep",
19    # Add a flag to test that they're exposed to the build script
20    rustc_flags = ["--cfg=foo=\"bar\""],
21    toolchains = ["//rust/toolchain:current_rust_toolchain"],
22    tools = [":tool"],
23)
24
25write_file(
26    name = "tool",
27    out = "tool-file",
28    content = [""],
29)
30
31rust_test(
32    name = "tools_exec",
33    srcs = ["tools_exec.rs"],
34    edition = "2018",
35    deps = [":tools_exec_build_rs"],
36)