Reputation: 131
I'm trying to set an environment variable for my mocha_test
rule in a Bazel BUILD file to provide the absolute path to a directory that's created using a genrule. The genrule is responsible for creating the directory and processing some dependencies, but I'm not sure how to pass the correct absolute path using "location".
Here's my current BUILD file:
genrule(
name = "app_dir_rule",
srcs = [],
outs = ["app_dir"],
cmd = """
mkdir -p $@
$(location :app_binary) process_dependencies --output=$@/vendor
cp $(location :app_binary) $@
""",
tools = [":app_binary"],
visibility = ["//visibility:private"],
)
mocha_test(
name = "mocha",
args = ["--inspect"],
chdir = package_name(),
data = [
":.mocharc.js",
":.prettierignore",
...
":app_dir_rule"
],
env = {
"APP_DIR": "$(location :app_dir_rule)"
},
tags = ["local"],
)
Could anyone help me to figure out the correct way to pass the absolute path for my application directory in this Bazel BUILD file??
Upvotes: 0
Views: 3838