@@ -23,22 +23,31 @@ def _init(module_ctx):
2323 register_built_pkgconfig_toolchain = True ,
2424 )
2525
26- versions = {
27- "cmake" : _DEFAULT_CMAKE_VERSION ,
28- "ninja" : _DEFAULT_NINJA_VERSION ,
29- }
26+ cmake_version = _DEFAULT_CMAKE_VERSION
27+ ninja_version = _DEFAULT_NINJA_VERSION
3028
29+ # Traverse all modules starting from the root one (the first in
30+ # module_ctx.modules). The first occurrence of cmake or ninja tag wins.
31+ # Multiple versions requested from the same module are rejected.
3132 for mod in module_ctx .modules :
32- if not mod .is_root :
33- for toolchain in mod .tags .cmake :
34- versions ["cmake" ] = toolchain .version
33+ cmake_versions_count = len (mod .tags .cmake )
34+ if cmake_versions_count == 1 :
35+ cmake_version = mod .tags .cmake [0 ].version
36+ break
37+ elif cmake_versions_count > 1 :
38+ fail ("More than one cmake version requested: {}" .format (mod .tags .cmake ))
3539
36- for toolchain in mod .tags .ninja :
37- versions ["ninja" ] = toolchain .version
40+ for mod in module_ctx .modules :
41+ ninja_versions_count = len (mod .tags .ninja )
42+ if ninja_versions_count == 1 :
43+ ninja_version = mod .tags .cmake [0 ].version
44+ break
45+ elif ninja_versions_count > 1 :
46+ fail ("More than one ninja version requested: {}" .format (mod .tags .ninja ))
3847
3948 prebuilt_toolchains (
40- cmake_version = versions [ "cmake" ] ,
41- ninja_version = versions [ "ninja" ] ,
49+ cmake_version = cmake_version ,
50+ ninja_version = ninja_version ,
4251 register_toolchains = False ,
4352 )
4453
0 commit comments