fork/rules_rust

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

UebelAndreRenamed toolchain files targets (#1376)16175c88

0.11.0
1.7 KiB43 linesraw
1# Executable targets will output a pattern similar to the following
2# cargo 1.53.0 (4369396ce 2021-04-27)
3# Also Note, rustc_srcs is too big for this test
4_FILES = {
5    "cargo": ("--executable", r"^cargo [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
6    "clippy": ("--executable", r"^clippy [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
7    "rust_stdlib": ("--files", r"\.rlib"),
8    "rustc": ("--executable", r"^rustc [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
9    "rustc_lib": ("--files", r"rustc_driver"),
10    "rustdoc": ("--executable", r"^rustdoc [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
11    "rustfmt": ("--executable", r"^rustfmt [0-9\.]\+\-stable ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
12}
13
14# Generate a list manifest for all files in the filegroup
15[
16    genrule(
17        name = "{}_manifest_genrule".format(files),
18        srcs = ["//rust/toolchain:current_{}_files".format(files)],
19        outs = ["{}_manifest".format(files)],
20        cmd = "for file in $(rootpaths //rust/toolchain:current_{}_files); do echo $$file >> $@; done".format(files),
21    )
22    for files in _FILES
23    if "--files" in _FILES[files]
24]
25
26# Test that all toolchain tools are executable targets
27[
28    sh_test(
29        name = tool + "_test",
30        srcs = ["current_exec_files_test.sh"],
31        args = [
32            "$(rootpath //rust/toolchain:current_{}_files)".format(tool) if "--executable" == arg else "$(rootpath {}_manifest)".format(tool),
33            arg,
34            "'{}'".format(pattern),
35        ],
36        data = [
37            "//rust/toolchain:current_{}_files".format(tool),
38        ] + (
39            ["{}_manifest".format(tool)] if "--files" == arg else []
40        ),
41    )
42    for tool, (arg, pattern) in _FILES.items()
43]