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.
bzlmod: Improve SDK registration (bazel-contrib#3443)
Before this commit, users had to do the following in their `MODULE.bazel` file to register a custom Go SDK: ``` go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") go_sdk.download(name = "my_go", version = "1.19.5") use_repo(go_sdk, "my_go") register_toolchains("@my_go_toolchains//:all") ``` This has several drawbacks: * Names can collide with SDKs defined by transitive dependencies as they all live in the same namespace. * The SDK has to be brought into scope with `use_repo`. * Since the toolchain definitions are separate from the SDK repo, users need to know the naming convention for the separate toolchain repo for their `register_toolchains` calls. * It encourages using the SDK repo directly, which is almost never correct: Toolchain resolution should be used instead, possibly in the form of the new convenience target `@rules_go//go`. With this commit, Bazel toolchain definitions are emitted into a single repo and registered by rules_go itself. SDK repo names are mangled and kept as an implementation detail of rules_go. Module dependencies are no longer allowed to register SDKs with a non-mangled name, but an exception is made for the root module for the sake of backwards compatibility and to address unforeseen use cases. As a result of this change, SDK registration now looks as follows: ``` go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") go_sdk.download(version = "1.19.5") ```
- Loading branch information
Showing
9 changed files
with
348 additions
and
77 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 was deleted.
Oops, something went wrong.
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.