A command that takes the path of another command as an argument, and executes it using runfiles location after changing directory. E.g.
# This will change directory into `$BUILD_WORKSPACE_DIRECTORY`
# and then invoke `buildozer` to generate some Bazel targets.
command(
name = "update_targets_cmd",
command = ":update_targets",
arguments = [
"--buildozer",
"$(rootpath :buildozer)",
],
data = [":buildozer"],
)
command(
name = "buildozer",
command = select({
"@platforms//os:linux": "@com_github_bazelbuild_buildtools_buildozer_linux_amd64//file",
"@platforms//os:macos": "@com_github_bazelbuild_buildtools_buildozer_darwin_amd64//file",
"@platforms//os:windows": "@com_github_bazelbuild_buildtools_buildozer_windows_amd64//file",
}),
)
This fails to find the buildozer binary when executing update_targets because the bash script generated by command attempts to execute .short_path directly relative to the current working directory.
To support this use-case the generated bash script would have to look up the target executable using rlocation.
Consider the following use-case:
A
command
that takes the path of anothercommand
as an argument, and executes it using runfiles location after changing directory. E.g.This fails to find the buildozer binary when executing
update_targets
because the bash script generated bycommand
attempts to execute.short_path
directly relative to the current working directory.To support this use-case the generated bash script would have to look up the target executable using
rlocation
.