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

Add Label.to_display_form() #21179

Closed
wants to merge 2 commits into from
Closed

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Feb 1, 2024

Fixes #20486

While to_display_form() can be called in all contexts, it only returns apparent names for BUILD threads, which are the most common use case for display form labels. Support for module extensions can be added later, but requires explicit tracking of inverse mappings in the lockfile.

Also use to_display_form() to generate Clang module names in the correct form for external repositories. java_* rules require more delicate handling and will be migrated in a follow-up change.

RELNOTES: The to_display_form() method on Label returns a string representation of a label optimized for readability by humans.

@fmeum fmeum requested review from a team, Wyverald and meteorcloudy as code owners February 1, 2024 21:06
@fmeum fmeum requested review from gregestren and removed request for a team and gregestren February 1, 2024 21:06
@github-actions github-actions bot added team-Performance Issues for Performance teams team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Feb 1, 2024
@fmeum
Copy link
Collaborator Author

fmeum commented Feb 1, 2024

@Wyverald #21180 is the follow-up for Java. Feel free to also take a look, but it almost entirely affects Java rules only.

@fmeum fmeum removed team-Performance Issues for Performance teams team-Configurability platforms, toolchains, cquery, select(), config transitions labels Feb 1, 2024
throw result.getError().getException();
}
assertThat(result.get(skyKey).getModule().getGlobal("data"))
.isEqualTo("foo://:foo bar:@@data_repo~1.0//:bar baz:@@canonical_name//:baz");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh... why is this not bar:@data_repo//:bar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This verifies that to_display_form() doesn't return an apparent name in the context of a module extension, where if it did we would need to track that information in the lockfile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, because of BzlLoadFunction.java:1003.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We got some test failures while importing this change: https://buildkite.com/bazel/google-bazel-presubmit/builds/77054

The source is at https://bazel-review.googlesource.com/q/2098361e4a924e0e09dcd48c50235b38c5c5fd84

/cc @iancha1992 @fmeum Can you please check what's different?

Copy link
Collaborator Author

@fmeum fmeum Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests need to be updated now that my other PR has been merged. Will do that shortly and then you can reimport.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meteorcloudy Updated!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! @iancha1992 Please re-import!

@fmeum fmeum requested a review from Wyverald February 5, 2024 22:10
@fmeum
Copy link
Collaborator Author

fmeum commented Feb 6, 2024

@bazel-io fork 7.1.0

@Wyverald Wyverald added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Feb 8, 2024
Fixes bazelbuild#20486

Also use `to_display_form()` to generate Clang module names in the
correct form for external repositories. `java_*` rules require more
delicate handling and will be migrated in a follow-up change.

RELNOTES: The `to_display_form()` method on `Label` returns a string
representation of a label optimized for readability by humans.
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Feb 12, 2024
@fmeum fmeum deleted the 20486-to-display-name branch February 12, 2024 20:38
Wyverald pushed a commit that referenced this pull request Feb 12, 2024
Fixes #20486

While `to_display_form()` can be called in all contexts, it only returns apparent names for BUILD threads, which are the most common use case for display form labels. Support for module extensions can be added later, but requires explicit tracking of inverse mappings in the lockfile.

Also use `to_display_form()` to generate Clang module names in the correct form for external repositories. `java_*` rules require more delicate handling and will be migrated in a follow-up change.

RELNOTES: The `to_display_form()` method on `Label` returns a string representation of a label optimized for readability by humans.

Closes #21179.

PiperOrigin-RevId: 606330539
Change-Id: Id6a4ad79fd3d50319320789b88c618aad28db28b
Wyverald pushed a commit that referenced this pull request Feb 13, 2024
Fixes #20486

While `to_display_form()` can be called in all contexts, it only returns apparent names for BUILD threads, which are the most common use case for display form labels. Support for module extensions can be added later, but requires explicit tracking of inverse mappings in the lockfile.

Also use `to_display_form()` to generate Clang module names in the correct form for external repositories. `java_*` rules require more delicate handling and will be migrated in a follow-up change.

RELNOTES: The `to_display_form()` method on `Label` returns a string representation of a label optimized for readability by humans.

Closes #21179.

PiperOrigin-RevId: 606330539
Change-Id: Id6a4ad79fd3d50319320789b88c618aad28db28b
github-merge-queue bot pushed a commit that referenced this pull request Feb 13, 2024
Fixes #20486

While `to_display_form()` can be called in all contexts, it only returns
apparent names for BUILD threads, which are the most common use case for
display form labels. Support for module extensions can be added later,
but requires explicit tracking of inverse mappings in the lockfile.

Also use `to_display_form()` to generate Clang module names in the
correct form for external repositories. `java_*` rules require more
delicate handling and will be migrated in a follow-up change.

RELNOTES: The `to_display_form()` method on `Label` returns a string
representation of a label optimized for readability by humans.

Closes #21179.

PiperOrigin-RevId: 606330539
Change-Id: Id6a4ad79fd3d50319320789b88c618aad28db28b

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose "human usable" workspace names for labels
4 participants