-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bzlmod] Stop relying on initialize.release.bzl (#1127)
* [bzlmod] Stop relying on initialize.release.bzl * [release] Separate bzlmod dev extensions from release extensions In order to simplify the dependency tree for the rules kotlin bootstrap, bzlmod_setup needed to be separated from the release. The reason for this is twofold: kotlin_repositories in development call kt_configure which configures released_rules_kotlin. Since bzlmod_setup is also used to load released_rules_kotlin this become a dependency cycle. Second, we don't want to load released_rules_koltin in the release module, as it is a development dependency. (whoops.) This also allows dropping a few extra bits of configuration that are unnecessary for the release.
- Loading branch information
1 parent
b9380cd
commit a675511
Showing
4 changed files
with
74 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
def configure_modules_and_repositories(modules, kotlin_repositories, kotlinc_version, ksp_version): | ||
kotlinc = None | ||
ksp = None | ||
for mod in modules: | ||
for override in mod.tags.kotlinc_version: | ||
if kotlinc: | ||
fail("Only one kotlinc_version is supported right now!") | ||
kotlinc = kotlinc_version(release = override.version, sha256 = override.sha256) | ||
for override in mod.tags.ksp_version: | ||
if ksp: | ||
fail("Only one ksp_version is supported right now!") | ||
ksp = ksp_version(release = override.version, sha256 = override.sha256) | ||
|
||
kotlin_repositories_args = dict(is_bzlmod = True) | ||
if kotlinc: | ||
kotlin_repositories_args["compiler_release"] = kotlinc | ||
if ksp: | ||
kotlin_repositories_args["ksp_compiler_release"] = ksp | ||
|
||
kotlin_repositories(**kotlin_repositories_args) | ||
|
||
_version_tag = tag_class( | ||
attrs = { | ||
"version": attr.string(mandatory = True), | ||
"sha256": attr.string(mandatory = True), | ||
}, | ||
) | ||
|
||
tag_classes = { | ||
"kotlinc_version": _version_tag, | ||
"ksp_version": _version_tag, | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/starlark/core/repositories/bzlmod_setup.release.bzl
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
load( | ||
"//src/main/starlark/core/repositories:initialize.bzl", | ||
_kotlin_repositories = "kotlin_repositories", | ||
_kotlinc_version = "kotlinc_version", | ||
_ksp_version = "ksp_version", | ||
) | ||
load( | ||
":bzlmod_impl.bzl", | ||
"configure_modules_and_repositories", | ||
"tag_classes", | ||
) | ||
|
||
def _rules_kotlin_extensions_impl(mctx): | ||
configure_modules_and_repositories( | ||
mctx.modules, | ||
_kotlin_repositories, | ||
_kotlinc_version, | ||
_ksp_version, | ||
) | ||
|
||
rules_kotlin_extensions = module_extension( | ||
implementation = _rules_kotlin_extensions_impl, | ||
tag_classes = tag_classes, | ||
) |