rules_foreign_cc/foreign_cc/extensions.bzl

52 lines
1.5 KiB
Python

"""Entry point for extensions used by bzlmod."""
load("//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
load("//toolchains:prebuilt_toolchains.bzl", "prebuilt_toolchains")
_DEFAULT_CMAKE_VERSION = "3.23.2"
_DEFAULT_NINJA_VERSION = "1.12.1"
cmake_toolchain_version = tag_class(attrs = {
"version": attr.string(doc = "The cmake version", default = _DEFAULT_CMAKE_VERSION),
})
ninja_toolchain_version = tag_class(attrs = {
"version": attr.string(doc = "The ninja version", default = _DEFAULT_NINJA_VERSION),
})
def _init(module_ctx):
rules_foreign_cc_dependencies(
register_toolchains = False,
register_built_tools = True,
register_default_tools = False,
register_preinstalled_tools = False,
register_built_pkgconfig_toolchain = True,
)
versions = {
"cmake": _DEFAULT_CMAKE_VERSION,
"ninja": _DEFAULT_NINJA_VERSION,
}
for mod in module_ctx.modules:
if not mod.is_root:
for toolchain in mod.tags.cmake:
versions["cmake"] = toolchain.version
for toolchain in mod.tags.ninja:
versions["ninja"] = toolchain.version
prebuilt_toolchains(
cmake_version = versions["cmake"],
ninja_version = versions["ninja"],
register_toolchains = False,
)
tools = module_extension(
implementation = _init,
tag_classes = {
"cmake": cmake_toolchain_version,
"ninja": ninja_toolchain_version,
},
)