-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add a way to get the alias label in starlark #11044
Comments
I originally thought this is specifically harmful, but then realized that this functionality is already available to Java rules ( |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
Not stale. I would also love to have this for rules_xcodeproj. |
@lberki I would need this for #10309 (comment). Do you think this is safe enough that I could go ahead and implement it as a new struct field on Edit: While looking into this for a bit, it seemed simple enough that I went ahead and turned it into a PR: #18100 |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
@bazelbuild/triage not stale |
Found a fun way to hack this with a macro btw:
Then you have the original alias, and target maping available: |
Description of the problem / feature request:
Within starlark, it would be useful to be able to access the original label (i.e. the alias label itself, and not the actual alias) of an alias label.
For example, if a rule was
foo_rule(deps = ["/some/alias"])
, in the rule impl we would like to do something likefor dep in ctx.attr.deps: if hasattr(dep, 'alias_original_label'): do_something(deps.alias_original_label)
and this would, for the above dep, dodo_something("/some/alias")
.To be specific, the desire would be to expose
AliasConfiguredTarget.label
to starlark.I don't think this would be too complex to implement and could try to do it, as long as this aligns with the principles of bazel.
Feature requests: what underlying problem are you trying to solve with this feature?
We are trying to do some analysis during the build of the dependencies of a given rule, to make sure it conforms with some principles that we want, and would like to handle aliases specially for certain reasons. Having this ability would help us do so. It is useful for us that this is in starlark itself, rather than relying on
bazel query
or similar.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Not a bug
What operating system are you running Bazel on?
Linux
What's the output of
bazel info release
?release 1.0.0
(but docs don't show this ability still)If
bazel info release
returns "development version" or "(@Non-Git)", tell us how you built Bazel.N/A
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?N/A
Have you found anything relevant by searching the web?
No
Any other information, logs, or outputs that you want to share?
No
The text was updated successfully, but these errors were encountered: