-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
52 additions
and
10 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
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,35 @@ | ||
"extensions for bzlmod" | ||
|
||
load(":repositories.bzl", "swc_register_toolchains") | ||
|
||
swc_toolchain = tag_class(attrs = { | ||
"name": attr.string(doc = "Base name for generated repositories"), | ||
"swc_version": attr.string(doc = "Version of the swc rust binding"), | ||
}) | ||
|
||
def _toolchain_extension(module_ctx): | ||
registrations = {} | ||
for mod in module_ctx.modules: | ||
for toolchain in mod.tags.toolchain: | ||
if toolchain.name in registrations.keys(): | ||
if toolchain.swc_version == registrations[toolchain.name]: | ||
# No problem to register a matching toolchain twice | ||
continue | ||
fail("Multiple conflicting toolchains declared for name {} ({} and {}".format( | ||
toolchain.name, | ||
toolchain.swc_version, | ||
registrations[toolchain.name], | ||
)) | ||
else: | ||
registrations[toolchain.name] = toolchain.swc_version | ||
for name, swc_version in registrations.items(): | ||
swc_register_toolchains( | ||
name = name, | ||
swc_version = swc_version, | ||
register = False, | ||
) | ||
|
||
swc = module_extension( | ||
implementation = _toolchain_extension, | ||
tag_classes = {"toolchain": swc_toolchain}, | ||
) |
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