Skip to content

Commit 84a540e

Browse files
committed
Improve gradle script
1 parent 1a67a71 commit 84a540e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

core/platform/android/libcocos2dx/axistools.gradle

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,25 @@ class axistools {
162162
def sdkRoot = Paths.get("${System.env.ANDROID_SDK}")
163163

164164
if(Files.exists(sdkRoot)) {
165+
def verList = []
166+
167+
// Scan installed cmake in $sdk_root/cmake
168+
File sdkCMakeDir = new File(sdkRoot.toAbsolutePath().toString() + '/cmake')
169+
if (sdkCMakeDir.isDirectory()) {
170+
for (cmakeDir in sdkCMakeDir.listFiles()) {
171+
verList.add(cmakeDir.getName())
172+
}
173+
}
174+
175+
// Sort cmake verList
176+
verList.sort {a,b ->
177+
return axistools.compareVersion(b, a)
178+
}
179+
180+
// Collect cmakeBinDirs for search
165181
sdkRoot = sdkRoot.toAbsolutePath().toString()
166-
def verList = ["3.10.2.4988404", "3.18.1"]
167182
for(foundVer in verList){
168183
cmakeBinDir = sdkRoot + File.separator + "cmake" + File.separator + foundVer + File.separator + "bin"
169-
170184
if(new File(cmakeBinDir).isDirectory()) {
171185
cmakeBinDirs.add(cmakeBinDir)
172186
}
@@ -238,7 +252,7 @@ class axistools {
238252

239253
String ninjaPath = cmakeBin + File.separator + getNinjaProgramName()
240254
if(!new File(ninjaPath).isFile()) {
241-
println("The required ninja program is not present in cmake bin dir!")
255+
println("The required ninja program is not present in cmake bin dir: '$cmakeBin'")
242256
return null
243257
}
244258

0 commit comments

Comments
 (0)