fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
d974e0ea
0.11.0
1load ( "@rules_rust//cargo:cargo_build_script.bzl" , "cargo_build_script" ) 2load ( "@rules_rust//rust:defs.bzl" , "rust_test" ) 3 4# generate a file 5genrule ( 6name = "data_generator" , 7outs = [ "generated.data" ], 8cmd = "echo hello > $@" , 9) 10 11_data = [ 12# we should be able to read non-generated source/data files 13"source.file" , 14# and generated files as well 15"generated.data" , 16# we should also be able to access external binaries 17# such as protoc. 18"@com_google_protobuf//:protoc" , 19] 20 21cargo_build_script ( 22name = "build" , 23srcs = [ "build.rs" ], 24build_script_env = { 25"GENERATED_DATA" : "$(location generated.data)" , 26"SOME_TOOL" : "$(execpath @com_google_protobuf//:protoc)" , 27# both execpath and location should work 28"SOURCE_FILE" : "$(execpath source.file)" , 29}, 30data = _data , 31) 32 33rust_test ( 34name = "test" , 35srcs = [ 36"main.rs" , 37], 38data = _data , 39edition = "2018" , 40rustc_env = { 41"GENERATED_DATA_ABS" : "$(execpath generated.data)" , 42"GENERATED_DATA_ROOT" : "$(rootpath generated.data)" , 43"SOME_TOOL" : "$(rootpath @com_google_protobuf//:protoc)" , 44"SOURCE_FILE" : "$(rootpath source.file)" , 45}, 46deps = [ 47":build" , 48], 49)