[9.0.0] Add ctx.package_relative_label#28185
Merged
iancha1992 merged 1 commit intorelease-9.0.0from Jan 8, 2026
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds ctx.package_relative_label, a new Starlark function for rule contexts to convert a string to a Label relative to the currently analyzed target's package. The implementation is sound, documentation is updated, and the new functionality is well-tested. The changes are of high quality.
This is necessary to permit Starlark implementations of `ctx.expand_location`, which can be more memory efficient, support path mapping and provide better defaults. RELNOTES: The new `package_relative_label` function on the rule context (`ctx`) can be used to turn a user-provided label string into a `Label` relative to the target that is currently being analyzed (where `Label(...)` would return a `Label` relative to the `.bzl` file containing the call). Closes #28102. PiperOrigin-RevId: 853170854 Change-Id: Ibecff3b0b599da0be2fbbba707c15ed540c6c38c
iancha1992
approved these changes
Jan 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is necessary to permit Starlark implementations of
ctx.expand_location, which can be more memory efficient, support path mapping and provide better defaults.RELNOTES: The new
package_relative_labelfunction on the rule context (ctx) can be used to turn a user-provided label string into aLabelrelative to the target that is currently being analyzed (whereLabel(...)would return aLabelrelative to the.bzlfile containing the call).Closes #28102.
PiperOrigin-RevId: 853170854
Change-Id: Ibecff3b0b599da0be2fbbba707c15ed540c6c38c