22
33load ("@bazel_features//:features.bzl" , "bazel_features" )
44load ("//foreign_cc:repositories.bzl" , "rules_foreign_cc_dependencies" )
5+ load ("//foreign_cc/private:default_versions.bzl" , _DEFAULT_VERSIONS = "DEFAULT_VERSIONS" )
56load ("//toolchains:prebuilt_toolchains.bzl" , "prebuilt_toolchains" )
67
7- _DEFAULT_CMAKE_VERSION = "3.31.7"
8- _DEFAULT_NINJA_VERSION = "1.12.1"
9-
108cmake_toolchain_version = tag_class (attrs = {
11- "version" : attr .string (doc = "The cmake version" , default = _DEFAULT_CMAKE_VERSION ),
9+ "version" : attr .string (doc = "The cmake version" , default = _DEFAULT_VERSIONS ["cmake" ]),
10+ })
11+
12+ make_toolchain_version = tag_class (attrs = {
13+ "version" : attr .string (doc = "The make version" , default = _DEFAULT_VERSIONS ["make" ]),
14+ })
15+
16+ meson_toolchain_version = tag_class (attrs = {
17+ "version" : attr .string (doc = "The meson version" , default = _DEFAULT_VERSIONS ["meson" ]),
1218})
1319
1420ninja_toolchain_version = tag_class (attrs = {
15- "version" : attr .string (doc = "The ninja version" , default = _DEFAULT_NINJA_VERSION ),
21+ "version" : attr .string (doc = "The ninja version" , default = _DEFAULT_VERSIONS ["ninja" ]),
22+ })
23+
24+ pkgconfig_toolchain_version = tag_class (attrs = {
25+ "version" : attr .string (doc = "The pkgconfig version" , default = _DEFAULT_VERSIONS ["pkgconfig" ]),
1626})
1727
1828def _init (module_ctx ):
29+ versions = dict (_DEFAULT_VERSIONS )
30+
31+ pinned_kw = {}
32+
33+ for mod in module_ctx .modules :
34+ if not mod .is_root :
35+ for toolchain_type in versions .keys ():
36+ for toolchain in getattr (mod .tags , toolchain_type ):
37+ versions [toolchain_type ] = toolchain .version
38+ pinned_kw [toolchain_type + "_version" ] = toolchain .version
39+
1940 rules_foreign_cc_dependencies (
2041 register_toolchains = False ,
2142 register_built_tools = True ,
@@ -24,21 +45,9 @@ def _init(module_ctx):
2445 register_built_pkgconfig_toolchain = True ,
2546 # These should be registered via bzlmod entries instead
2647 register_repos = False ,
48+ ** pinned_kw
2749 )
2850
29- versions = {
30- "cmake" : _DEFAULT_CMAKE_VERSION ,
31- "ninja" : _DEFAULT_NINJA_VERSION ,
32- }
33-
34- for mod in module_ctx .modules :
35- if not mod .is_root :
36- for toolchain in mod .tags .cmake :
37- versions ["cmake" ] = toolchain .version
38-
39- for toolchain in mod .tags .ninja :
40- versions ["ninja" ] = toolchain .version
41-
4251 prebuilt_toolchains (
4352 cmake_version = versions ["cmake" ],
4453 ninja_version = versions ["ninja" ],
@@ -54,6 +63,9 @@ tools = module_extension(
5463 implementation = _init ,
5564 tag_classes = {
5665 "cmake" : cmake_toolchain_version ,
66+ "make" : make_toolchain_version ,
67+ "meson" : meson_toolchain_version ,
5768 "ninja" : ninja_toolchain_version ,
69+ "pkgconfig" : pkgconfig_toolchain_version ,
5870 },
5971)
0 commit comments