Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow predeclared outputs to be used in ctx.expand_location #24573

Open
Silic0nS0ldier opened this issue Dec 5, 2024 · 0 comments
Open

Allow predeclared outputs to be used in ctx.expand_location #24573

Silic0nS0ldier opened this issue Dec 5, 2024 · 0 comments
Labels
team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request untriaged

Comments

@Silic0nS0ldier
Copy link
Contributor

Description of the feature request:

ctx.expand_location allows rules to implement the $(location ...) expansion functionality present in genrule, partially. It will only expand inputs.

Supporting outputs (i.e. attr.output and attr.output_list) would be useful for genrule equivalent rules like run_binary and js_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 returns development 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

4 participants