-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow configuring meson, make and pkgconfig versions via bzlmod exten…
…sion
- Loading branch information
Showing
5 changed files
with
69 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,69 @@ | ||
"""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.11.1" | ||
load("//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies", "DEFAULT_CMAKE_VERSION", "DEFAULT_MAKE_VERSION", "DEFAULT_MESON_VERSION", "DEFAULT_NINJA_VERSION", "DEFAULT_PKGCONFIG_VERSION") | ||
load("//toolchains:built_toolchains.bzl", "make_toolchain", "meson_toolchain", "pkgconfig_toolchain") | ||
load("//toolchains:prebuilt_toolchains.bzl", "cmake_toolchains", "ninja_toolchains") | ||
|
||
cmake_toolchain_version = tag_class(attrs = { | ||
"version": attr.string(doc = "The cmake version", default = _DEFAULT_CMAKE_VERSION), | ||
"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), | ||
make_toolchain_version = tag_class(attrs = { | ||
"version": attr.string(doc = "The GNU Make version", default = DEFAULT_MAKE_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, | ||
) | ||
meson_toolchain_version = tag_class(attrs = { | ||
"version": attr.string(doc = "The meson version", default = DEFAULT_MESON_VERSION), | ||
}) | ||
|
||
ninja_toolchain_version = tag_class(attrs = { | ||
"version": attr.string(doc = "The ninja version", default = DEFAULT_NINJA_VERSION), | ||
}) | ||
|
||
versions = { | ||
"cmake": _DEFAULT_CMAKE_VERSION, | ||
"ninja": _DEFAULT_NINJA_VERSION, | ||
} | ||
pkgconfig_toolchain_version = tag_class(attrs = { | ||
"version": attr.string(doc = "The pkgconfig version", default = DEFAULT_PKGCONFIG_VERSION), | ||
}) | ||
|
||
def _init(module_ctx): | ||
for mod in module_ctx.modules: | ||
if not mod.is_root: | ||
if mod.is_root: | ||
for toolchain in mod.tags.cmake: | ||
versions["cmake"] = toolchain.version | ||
cmake_toolchains(toolchain.version, register_toolchains = False) | ||
|
||
for toolchain in mod.tags.make: | ||
make_toolchain(toolchain.version, register_toolchains = False) | ||
|
||
for toolchain in mod.tags.meson: | ||
meson_toolchain(toolchain.version, register_toolchains = False) | ||
|
||
for toolchain in mod.tags.ninja: | ||
versions["ninja"] = toolchain.version | ||
ninja_toolchains(toolchain.version, register_toolchains = False) | ||
|
||
for toolchain in mod.tags.pkgconfig: | ||
pkgconfig_toolchain(toolchain.version, register_toolchains = False) | ||
|
||
prebuilt_toolchains( | ||
cmake_version = versions["cmake"], | ||
ninja_version = versions["ninja"], | ||
cmake_toolchains(DEFAULT_CMAKE_VERSION, register_toolchains = False) | ||
make_toolchain(DEFAULT_MAKE_VERSION, register_toolchains = False) | ||
meson_toolchain(DEFAULT_MESON_VERSION, register_toolchains = False) | ||
ninja_toolchains(DEFAULT_NINJA_VERSION, register_toolchains = False) | ||
pkgconfig_toolchain(DEFAULT_PKGCONFIG_VERSION, register_toolchains = False) | ||
|
||
rules_foreign_cc_dependencies( | ||
register_toolchains = False, | ||
register_built_tools = True, | ||
register_default_tools = False, | ||
register_preinstalled_tools = False, | ||
register_built_pkgconfig_toolchain = False, | ||
) | ||
|
||
|
||
tools = module_extension( | ||
implementation = _init, | ||
tag_classes = { | ||
"cmake": cmake_toolchain_version, | ||
"make": make_toolchain_version, | ||
"meson": meson_toolchain_version, | ||
"ninja": ninja_toolchain_version, | ||
"pkgconfig": pkgconfig_toolchain_version, | ||
}, | ||
) |
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