Allow predeclared outputs to be used in ctx.expand_location
#24573
Labels
team-Rules-API
API for writing rules/aspects: providers, runfiles, actions, artifacts
type: feature request
untriaged
Description of the feature request:
ctx.expand_location
allows rules to implement the$(location ...)
expansion functionality present ingenrule
, partially. It will only expand inputs.Supporting outputs (i.e.
attr.output
andattr.output_list
) would be useful forgenrule
equivalent rules likerun_binary
andjs_run_binary
. Without this it is tricky to instruct the tool where the output should be written, encouraging brittle solutions like hard coding output paths in the executable (may break when refactoring or even worse whenever the target platform changes).There is also a gap in the documentation here.
ctx.expand_location
doesn't note the limitation and https://bazel.build/reference/be/make-variables#predefined_label_variables implies this should work everywhere expansion can be performed. These docs aren't linked either (#11321).Which category does this issue belong to?
Rules API
What underlying problem are you trying to solve with this feature?
Correctly referencing rule outputs in arguments in general purpose
genrule
-like rules.Which operating system are you running Bazel on?
No response
What is the output of
bazel info release
?No response
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: