@@ -18,19 +18,19 @@ class _CmakeResolver implements ToolResolver {
1818 final executableName = OS .current.executableFileName ('cmake' );
1919
2020 @override
21- Future <List <ToolInstance >> resolve ({required Logger ? logger, UserConfig ? userConfig, CodeConfig ? codeConfig}) async {
21+ Future <List <ToolInstance >> resolve ({required Logger ? logger, UserConfig ? userConfig}) async {
22+ // here, we always try to find android cmake first and filter out unsatisfied versions
2223 final androidResolver = CliVersionResolver (
2324 wrappedResolver: ToolResolvers ([
24- if ((userConfig? .preferAndroidCmake ?? false ) || (codeConfig? .targetOS == OS .android))
25- InstallLocationResolver (
26- toolName: 'CMake' ,
27- paths: [
28- if (userConfig? .androidHome != null ) '${userConfig ?.androidHome }/cmake/*/bin/$executableName ' ,
29- if (Platform .isLinux) r'$HOME/Android/Sdk/cmake/*/bin/' + executableName,
30- if (Platform .isMacOS) r'$HOME/Library/Android/sdk/cmake/*/bin/' + executableName,
31- if (Platform .isWindows) r'$HOME/AppData/Local/Android/Sdk/cmake/*/bin/' + executableName,
32- ],
33- ),
25+ InstallLocationResolver (
26+ toolName: 'CMake' ,
27+ paths: [
28+ if (userConfig? .androidHome != null ) '${userConfig ?.androidHome }/cmake/*/bin/$executableName ' ,
29+ if (Platform .isLinux) r'$HOME/Android/Sdk/cmake/*/bin/' + executableName,
30+ if (Platform .isMacOS) r'$HOME/Library/Android/sdk/cmake/*/bin/' + executableName,
31+ if (Platform .isWindows) r'$HOME/AppData/Local/Android/Sdk/cmake/*/bin/' + executableName,
32+ ],
33+ ),
3434 ]),
3535 );
3636 final androidCmakeInstances = await androidResolver.resolve (logger: logger);
@@ -45,7 +45,7 @@ class _CmakeResolver implements ToolResolver {
4545 // sort latest version first
4646 androidCmakeInstances.sort ((a, b) => a.version! > b.version! ? - 1 : 1 );
4747 final combinedCmakeInstances = < ToolInstance > [];
48- if (( userConfig? .preferAndroidCmake ?? false ) || (codeConfig ? .targetOS == OS .android) ) {
48+ if (userConfig? .preferAndroidCmake ?? userConfig ? .targetOS == OS .android) {
4949 combinedCmakeInstances.addAll (androidCmakeInstances);
5050 }
5151 combinedCmakeInstances.addAll (systemCmakeInstances);
@@ -55,29 +55,25 @@ class _CmakeResolver implements ToolResolver {
5555 }
5656 }
5757
58- String ? specificCmakeVersion;
59- if (codeConfig? .targetOS == OS .android && userConfig? .androidTargetCmakeVersion != null ) {
60- specificCmakeVersion = userConfig? .androidTargetCmakeVersion;
61- } else {
62- specificCmakeVersion = userConfig? .cmakeVersion;
63- }
64-
58+ final specificCmakeVersion = userConfig? .cmakeVersion;
6559 if (specificCmakeVersion != null ) {
6660 final cmakeVer = Version .parse (specificCmakeVersion);
6761 logger? .info ('Filtering CMake version: $cmakeVer ' );
68- logger? .info ('Found CMake: ${combinedCmakeInstances .map ((e ) => e .toString ()).join (', ' )}' );
6962 // cmake version of android are likely to be the format of `3.22.1-g37088a8-dirty`
7063 // so here we just check the major, minor and patch version
71- combinedCmakeInstances.removeWhere ((instance) {
72- return instance.version == null ||
73- (instance.version! .major != cmakeVer.major &&
74- instance.version! .minor != cmakeVer.minor &&
75- instance.version! .patch != cmakeVer.patch);
76- });
77- if (combinedCmakeInstances.isEmpty) {
78- logger? .severe ('Failed to find cmake version: $specificCmakeVersion ' );
79- throw Exception ('Failed to find cmake version: $specificCmakeVersion ' );
80- }
64+ combinedCmakeInstances.removeWhere (
65+ (instance) =>
66+ instance.version == null ||
67+ instance.version? .major != cmakeVer.major ||
68+ instance.version? .minor != cmakeVer.minor ||
69+ instance.version? .patch != cmakeVer.patch,
70+ );
71+ }
72+
73+ logger? .info ('Found CMake: ${combinedCmakeInstances .map ((e ) => e .toString ()).join (', ' )}' );
74+ if (combinedCmakeInstances.isEmpty) {
75+ logger? .severe ('Failed to find cmake with version=${specificCmakeVersion ?? 'latest' }' );
76+ throw Exception ('Failed to find cmake version: ${specificCmakeVersion ?? 'latest' }' );
8177 }
8278
8379 return combinedCmakeInstances;
0 commit comments