Skip to content

Commit

Permalink
Adding tag_classes to select versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsharpe committed Mar 20, 2023
1 parent 0a0ad90 commit c96d5a5
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions foreign_cc/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,49 @@

load("//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

def _init(_):
rules_foreign_cc_dependencies(register_toolchains = False, register_preinstalled_tools = False, register_built_pkgconfig_toolchain = True)
_DEFAULT_CMAKE_VERSION = "3.23.2"
_DEFAULT_NINJA_VERSION = "1.11.1"

tools = module_extension(implementation = _init)
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 = False,
register_default_tools = False,
register_preinstalled_tools = False,
register_built_pkgconfig_toolchain = True,
)

versions = {
"cmake": "3.23.2",
"ninja": "1.11.1",
}

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_version,
},
)

0 comments on commit c96d5a5

Please sign in to comment.