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

Use rctx.original_name if available, Go 1.23.6 #1694

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Feb 6, 2025

Description

Prepares for repository_ctx.original_name support in Bazel 8.1.0 per bazelbuild/bazel#24467 and bumps Go to 1.23.6. Part of #1482 and #1652.

The underlying repo rules will now use repository_ctx.original_name if it's available.

I've confirmed that these changes use repository_ctx.original_name under Bazel 8.1.0rc2 after commenting out the wrappers and restoring the original repo rule symbols.

Motivation

This change ensures compatibility with future Bazel releases. New comments indicate where to simplify code after dropping support for Bazel versions that don't have repository_ctx.original_name.

The Go 1.23.6 bump is a convenience update that isn't essential to the rest of the change.

Under Bzlmod, repository_ctx.name contains the canonical repository name. This broke the _alias_repository and jvm_import_external repository rules, which used repository_ctx.name to generate default top level target names for their repos. #1650 added wrapper macros passing the original name as an extra attribute to the underlying repo rules as a portable workaround.

The Bazel maintainers eventually recognized this as a common use case and added repository_ctx.original_name to eliminate the need for such wrappers (eventually).

Prepares for `repository_ctx.original_name` support in Bazel 8.1.0 per
bazelbuild/bazel#24467 and bumps Go to 1.23.6. Part of bazelbuild#1482 and bazelbuild#1652.

The underlying repo rules will now use `repository_ctx.original_name` if
it's available.

I've confirmed that these changes use `repository_ctx.original_name`
under Bazel 8.1.0rc2 after commenting out the wrappers and restoring the
original repo rule symbols.

---

This change ensures compatibility with future Bazel releases. New
comments indicate where to simplify code after dropping support for
Bazel versions that don't have `repository_ctx.original_name`.

The Go 1.23.6 bump is a convenience update that isn't essential to the
rest of the change.

Under Bzlmod, `repository_ctx.name` contains the canonical repository
name. This broke the `_alias_repository` and `jvm_import_external`
repository rules, which used `repository_ctx.name` to generate default
top level target names for their repos. bazelbuild#1650 added wrapper macros
passing the original name as an extra attribute to the underlying repo
rules as a portable workaround.

The Bazel maintainers eventually recognized this as a common use case
and added `repository_ctx.original_name` to eliminate the need for such
wrappers (eventually).

- https://bazel.build/rules/lib/builtins/repository_ctx#name
- https://bazel.build/rules/lib/builtins/repository_ctx#original_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant