Basic bzlmod setup (#3047)
* Replace Label(...).workspace_name with explicit repo name
With the repository mappings used by bzlmod, the
Label(...).workspace_name construct always returns the canonical,
post-repo mapping repo name, which can't be used to construct a valid
label. Until https://github.com/bazelbuild/bazel/issues/15593 has been
fixed, we have to hardcode the non-canonical repo name here.
* Remove remaining repo-absolute labels in load statements
* Refactor repository macros for bzlmod
The existing repository macros can be reused for the module setup
with only very few fully backwards compatible changes:
* The macros wrapping the Go SDK repository rules should make toolchain
registration optional. With bzlmod, toolchains are registered with the
toolchains_to_register attribute of the module function instead.
* The repository macro should not use _maybe with bzlmod. Instead, repos
loaded by module extensions are given globally unique internal names
automatically.
* Add basic bzlmod setup
This commit adds a MODULE.bazel that makes rules_go usable as a bzlmod
module for basic use cases.
The new module definition is verified by a test module that will be used
in the presubmit tests of the Bazel Central Registry (BCR).
The following features require more thought and/or work and are not yet
supported:
* SDK rules other than go_host_sdk and go_download_sdk.
* non-no-op nogo
* go_proto_library
17 files changed