fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
941c7cca
rust-analyzer
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 ( 9name = "tools_exec_build_rs" , 10srcs = [ "build.rs" ], 11build_script_env = { "TOOL" : "$(execpath :tool)" }, 12edition = "2018" , 13# Add a flag to test that they're exposed to the build script 14rustc_flags = [ "--verbose" ], 15tools = [ ":tool" ], 16) 17 18write_file ( 19name = "tool" , 20out = "tool-file" , 21content = [ "" ], 22) 23 24rust_test ( 25name = "tools_exec" , 26srcs = [ "tools_exec.rs" ], 27edition = "2018" , 28deps = [ ":tools_exec_build_rs" ], 29) 30 31environment_group ( 32name = "foo_environment" , 33defaults = [ ":foo" ], 34environments = [ 35":foo" , 36":bar" , 37], 38) 39 40environment ( 41name = "foo" , 42) 43 44environment ( 45name = "bar" , 46) 47 48rust_library ( 49name = "build_script_dep_without_compatible_with" , 50srcs = [ "lib.rs" ], 51edition = "2018" , 52) 53 54cargo_build_script ( 55name = "empty_build_script" , 56srcs = [ "do_nothing.rs" ], 57compatible_with = [ ":bar" ], 58edition = "2018" , 59deps = [ ":build_script_dep_without_compatible_with" ], 60) 61 62rust_test ( 63name = "test_compatible_with" , 64srcs = [ "lib.rs" ], 65compatible_with = [ ":bar" ], 66edition = "2018" , 67deps = [ ":empty_build_script" ], 68)