forked from bazel-contrib/rules_go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract generated code from BUILD.toolchains.bazel into a macro (baze…
…l-contrib#3439) As a macro, the code is cleaner and easier to reuse. In a follow-up change, it will be used to simplify toolchain registration with Bzlmod. This commit also removes the public `declare_toolchains` macro. It only seemed to be public since it was accessed by the generated SDK repos. It has never been documented and subject to backwards incompatible changes in recent releases.
- Loading branch information
Showing
7 changed files
with
95 additions
and
109 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,16 @@ | ||
load("@{rules_go_repo_name}//go/private:go_toolchain.bzl", "declare_bazel_toolchains") | ||
load("@bazel_skylib//lib:selects.bzl", "selects") | ||
load("@io_bazel_rules_go//go/private:go_toolchain.bzl", "declare_bazel_toolchains") | ||
|
||
{version_constants} | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
sdk_version_label = "@{rules_go_repo_name}//go/toolchain:sdk_version" | ||
|
||
config_setting( | ||
name = "match_all_versions", | ||
flag_values = { | ||
sdk_version_label: "", | ||
}, | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
config_setting( | ||
name = "match_major_version", | ||
flag_values = { | ||
sdk_version_label: MAJOR_VERSION, | ||
}, | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
config_setting( | ||
name = "match_major_minor_version", | ||
flag_values = { | ||
sdk_version_label: MAJOR_VERSION + "." + MINOR_VERSION, | ||
}, | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
config_setting( | ||
name = "match_patch_version", | ||
flag_values = { | ||
sdk_version_label: MAJOR_VERSION + "." + MINOR_VERSION + "." + PATCH_VERSION, | ||
}, | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
# If prerelease version is "", this will be the same as ":match_patch_version", but that's fine since we use match_any in config_setting_group. | ||
config_setting( | ||
name = "match_prerelease_version", | ||
flag_values = { | ||
sdk_version_label: MAJOR_VERSION + "." + MINOR_VERSION + "." + PATCH_VERSION + PRERELEASE_SUFFIX, | ||
}, | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
config_setting( | ||
name = "match_sdk_type", | ||
flag_values = { | ||
sdk_version_label: "{sdk_type}", | ||
}, | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
selects.config_setting_group( | ||
name = "sdk_version_setting", | ||
match_any = [ | ||
":match_all_versions", | ||
":match_major_version", | ||
":match_major_minor_version", | ||
":match_patch_version", | ||
":match_prerelease_version", | ||
":match_sdk_type", | ||
], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
declare_bazel_toolchains( | ||
go_toolchain_repo = "@{sdk_repo}", | ||
host_goarch = "{goarch}", | ||
host_goos = "{goos}", | ||
sdk_version_setting = ":sdk_version_setting", | ||
toolchain_prefix = "@{sdk_repo}//", | ||
major = MAJOR_VERSION, | ||
minor = MINOR_VERSION, | ||
patch = PATCH_VERSION, | ||
prerelease = PRERELEASE_SUFFIX, | ||
sdk_type = "{sdk_type}", | ||
) |
This file contains 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
This file contains 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
This file contains 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