| # Executable targets will output a pattern similar to the following |
| # cargo 1.53.0 (4369396ce 2021-04-27) |
| # Also Note, rustc_srcs is too big for this test |
| _FILES = { |
| "cargo": ("--executable", r"^cargo [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
| "clippy": ("--executable", r"^clippy [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
| "rust_stdlib": ("--files", r"\.rlib"), |
| "rustc": ("--executable", r"^rustc [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
| "rustc_lib": ("--files", r"rustc_driver"), |
| "rustdoc": ("--executable", r"^rustdoc [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
| "rustfmt": ("--executable", r"^rustfmt [0-9\.]\+\-stable ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
| } |
| |
| # Generate a list manifest for all files in the filegroup |
| [ |
| genrule( |
| name = "{}_manifest_genrule".format(files), |
| srcs = ["//rust/toolchain:current_{}_files".format(files)], |
| outs = ["{}_manifest".format(files)], |
| cmd = "for file in $(rootpaths //rust/toolchain:current_{}_files); do echo $$file >> $@; done".format(files), |
| ) |
| for files in _FILES |
| if "--files" in _FILES[files] |
| ] |
| |
| # Test that all toolchain tools are executable targets |
| [ |
| sh_test( |
| name = tool + "_test", |
| srcs = ["current_exec_files_test.sh"], |
| args = [ |
| "$(rootpath //rust/toolchain:current_{}_files)".format(tool) if "--executable" == arg else "$(rootpath {}_manifest)".format(tool), |
| arg, |
| "'{}'".format(pattern), |
| ], |
| data = [ |
| "//rust/toolchain:current_{}_files".format(tool), |
| ] + ( |
| ["{}_manifest".format(tool)] if "--files" == arg else [] |
| ), |
| ) |
| for tool, (arg, pattern) in _FILES.items() |
| ] |