Given this BUILD
file for Bazel below, how can I get the absolute path to the top level of the compiler_files
file group? I have tried using $(location //X:Y)
and its variants, but I just get back a massive list of files with their paths relative to the sandbox. What is the idiomatic way to update the PATH environment variable in a genrule with a path to a tool provided in the tools
attribute?
package(default_visibility = ['//visibility:public'])
filegroup(
name = "script",
srcs = ["src/inspect.sh"],
)
genrule(
name = "inspect",
srcs = [":script"],
cmd = """
# Instead of /tmp below I need to refer to the path of one of the tools
# export PATH=/tmp:$$PATH
source $(location :script)
cp output.txt $(RULEDIR)/
""",
tools = [
"@emsdk//emscripten_toolchain:compiler_files"
],
outs = ["generated.txt"]
)