-
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wire go_sdk and go_toolchain together (#1607)
* go_toolchain has a new mandatory attribute, "sdk", which be something that provides GoSDK. * go_host_sdk, go_local_sdk, and go_download_sdk are now macros that wrap the old rules. Each rule declares toolchains in its BUILD.bazel file that work on the host architecture. The macro calls register_toolchains with these. * go_register_toolchains no longer calls register_toolchains, but it will an SDK rule if "go_sdk" isn't defined. This is a step toward allowing multiple SDKs to support multiple execution platforms. * Action inputs are narrowed to use go.sdk.tools and go.stdlib.libs rather than larger sets of files.
- Loading branch information
Showing
18 changed files
with
253 additions
and
203 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,64 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_sdk") | ||
load("@io_bazel_rules_go//go/toolchain:toolchains.bzl", "declare_toolchains") | ||
load("@io_bazel_rules_go//go/private:rules/sdk.bzl", "package_list") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
filegroup( | ||
name = "files", | ||
srcs = glob([ | ||
"bin/go*", | ||
"src/**", | ||
"pkg/**", | ||
]), | ||
name = "libs", | ||
srcs = glob( | ||
["pkg/{goos}_{goarch}/**/*.a"], | ||
exclude = ["pkg/{goos}_{goarch}/**/cmd/**"], | ||
), | ||
) | ||
|
||
filegroup( | ||
name = "headers", | ||
srcs = glob(["pkg/include/*.h"]), | ||
) | ||
|
||
filegroup( | ||
name = "srcs", | ||
srcs = glob(["src/**"]), | ||
) | ||
|
||
filegroup( | ||
name = "tools", | ||
srcs = glob(["pkg/tool/**"]), | ||
) | ||
|
||
go_sdk( | ||
name = "go_sdk", | ||
goos = "{goos}", | ||
goarch = "{goarch}", | ||
root_file = "ROOT", | ||
package_list = ":package_list", | ||
libs = [":libs"], | ||
headers = [":headers"], | ||
srcs = [":srcs"], | ||
tools = [":tools"], | ||
go = "bin/go{exe}", | ||
) | ||
|
||
# TODO(jayconrod): Gazelle depends on this file directly. This dependency | ||
# should be broken, and this rule should be folded into go_sdk. | ||
package_list( | ||
name = "package_list", | ||
srcs = [":srcs"], | ||
root_file = "ROOT", | ||
out = "packages.txt", | ||
) | ||
|
||
declare_toolchains( | ||
host = "{goos}_{goarch}", | ||
sdk = ":go_sdk", | ||
) | ||
|
||
filegroup( | ||
name = "files", | ||
srcs = glob([ | ||
"bin/go*", | ||
"pkg/tool/**", | ||
]) + select({ | ||
"@io_bazel_rules_go//go/platform:darwin_amd64": ["@local_config_cc//:cc_wrapper"], | ||
"//conditions:default": [], | ||
}), | ||
"src/**", | ||
"pkg/**", | ||
]), | ||
) | ||
|
||
exports_files(["packages.txt", "ROOT"]) |
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
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
Oops, something went wrong.