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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ load(

go_rules_dependencies()

go_register_toolchains(version = "1.23.5")
go_register_toolchains(version = "1.23.6")

http_archive(
name = "bazelci_rules",
Expand Down
6 changes: 5 additions & 1 deletion scala/scala_maven_import_external.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def _jvm_import_external_impl(repository_ctx):
if (repository_ctx.attr.generated_linkable_rule_name and
not repository_ctx.attr.neverlink):
fail("Only use generated_linkable_rule_name if neverlink is set")
repo_name = repository_ctx.name

# Replace with rctx.original_name once all supported Bazels have it
repo_name = getattr(repository_ctx, "original_name", repository_ctx.name)
name = repository_ctx.attr.generated_rule_name or repo_name
urls = repository_ctx.attr.jar_urls
if repository_ctx.attr.jar_sha256:
Expand Down Expand Up @@ -257,6 +259,8 @@ _jvm_import_external = repository_rule(
environ = [_FETCH_SOURCES_ENV_VAR_NAME],
)

# Remove this macro and restore `_jvm_import_external` to `jvm_import_external`
# once all supported Bazel versions support `repository_ctx.original_name`.
def jvm_import_external(**kwargs):
"""Wraps `_jvm_import_external` to pass `name` as `generated_target_name`.

Expand Down
7 changes: 5 additions & 2 deletions third_party/repositories/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def repositories(

def _alias_repository_impl(rctx):
""" Builds a repository containing just two aliases to the Scala Maven artifacts in the `target` repository. """

format_kwargs = {
"name": rctx.attr.default_target_name,
# Replace with rctx.original_name once all supported Bazels have it
"name": getattr(rctx, "original_name", rctx.attr.default_target_name),
"target": rctx.attr.target,
}
rctx.file("BUILD", """alias(
Expand All @@ -161,11 +161,14 @@ def _alias_repository_impl(rctx):
_alias_repository = repository_rule(
implementation = _alias_repository_impl,
attrs = {
# Remove once all supported Bazels have repository_ctx.original_name
"default_target_name": attr.string(mandatory = True),
"target": attr.string(mandatory = True),
},
)

# Remove this macro and use `_alias_repository` directly once all supported
# Bazel versions support `repository_ctx.original_name`.
def _alias_repository_wrapper(**kwargs):
"""Wraps `_alias_repository` to pass `name` as `default_target_name`."""
default_target_name = kwargs.pop("default_target_name", kwargs.get("name"))
Expand Down