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 new setting //go/toolchain:sdk_name to allow the selection of a specific Go toolchain #4242

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bluec0re
Copy link
Contributor

What type of PR is this?

Feature

What does this PR do? Why is it needed?

This commit adds a new setting
--@io_bazel_rules_go//go/toolchain:sdk_name which can be used to select a registered Go toolchain via the name provided in go_download_sdk, go_wrap_sdk, etc.

This fixes the problem of selecting a toolchain where the same Go version is used, but different experiements are enabled or patches applied.

Which issues(s) does this PR fix?

Fixes #4240

Other notes for review

Works also as a workaround for #3582

…pecific Go toolchain

This commit adds a new setting
--@io_bazel_rules_go//go/toolchain:sdk_name which can be used to select
a registered Go toolchain via the name provided in go_download_sdk,
go_wrap_sdk, etc.

This fixes the problem of selecting a toolchain where the same Go
version is used, but different experiements are enabled or patches
applied.

Fixes bazel-contrib#4240
@@ -200,6 +200,33 @@ def declare_bazel_toolchains(
visibility = ["//visibility:private"],
)

sdk_name_label = Label("//go/toolchain:sdk_name")
Copy link
Member

Choose a reason for hiding this comment

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

You can inline this and drop the Label(...) call, config_setting properly converts its attributes.

native.config_setting(
name = prefix + "match_sdk_name",
flag_values = {
sdk_name_label: go_toolchain_repo[1:] if go_toolchain_repo.startswith("@") else go_toolchain_repo,
Copy link
Member

Choose a reason for hiding this comment

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

I would like to avoid this kind of ad-hoc parsing. Can we arrange for the correct name to be passed in as an argument to the function?

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.

How can a specific sdk be selected for builds and tests?
2 participants