feat(sdk): allow per-platform strip_prefix via strip_prefixes#4622
Draft
albertocavalcante wants to merge 1 commit into
Draft
feat(sdk): allow per-platform strip_prefix via strip_prefixes#4622albertocavalcante wants to merge 1 commit into
albertocavalcante wants to merge 1 commit into
Conversation
The Go command (since 1.21) can fetch the toolchain as a standard Go
module named golang.org/toolchain, served by any GOPROXY-style mirror
(proxy.golang.org, Artifactory, Athens, Nexus, etc.). Unlike the
go.dev/dl layout, the per-platform archives each have a distinct
top-level directory of the form
golang.org/toolchain@v0.0.1-go{V}.{os}-{arch}
so a single strip_prefix string is not expressive enough to cover all
platforms in one go_download_sdk (or go_sdk.download) call.
Add a strip_prefixes attribute (string_dict, keyed by "<goos>_<goarch>")
that, when non-empty, takes precedence over strip_prefix. The existing
strip_prefix attribute and its default of "go" are unchanged, so every
existing rule_go consumer is unaffected.
Refs bazel-contrib#4516. This patch covers the minimum needed to serve the SDK
from any GOPROXY-style mirror today; the convenience wrapper that
auto-derives urls/sdks/strip_prefixes from a goproxy URL prefix is
deferred to a follow-up.
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.
What type of PR is this?
Feature
What does this PR do? Why is it needed?
rules_gocurrently can't fetch the Go SDK from a GOPROXY-style mirror because thegolang.org/toolchainmodule layout has a different top-level directory per platform (golang.org/toolchain@v0.0.1-go1.22.5.linux-amd64,...darwin-arm64, etc.), and a singlestrip_prefixcan't express that.So this adds a
strip_prefixesattr (per-platform dict) ongo_download_sdkand thego_sdk.downloadbzlmod tag. When set, it wins overstrip_prefix. Otherwise nothing changes.Which issues(s) does this PR fix?
Closes #4516
Other notes for review
There's an end-to-end test in
tests/core/go_download_sdk/go_download_sdk_test.gothat pulls Go 1.22.5 from the publicproxy.golang.org, so the new path actually runs on CI.Kept the scope to just the attribute. Auto-deriving
urls/sdks/strip_prefixesfrom agoproxy =arg can be a separate PR if there's appetite for it.The bzlmod tag was only smoke-tested locally with
bazel mod deps. The automated test covers WORKSPACE-modego_download_sdk, same rule underneath. Let me know if a BCR test for the tag would help.