Skip to content

Commit 1f46900

Browse files
authored
Improve gradle scripts (#2561)
- Move `axmol.gradle` outside the `libaxmol` gradle project - Fix gradle can't lookup cmake from `axmol/tools/external/cmake`
1 parent 082357f commit 1f46900

File tree

9 files changed

+49
-27
lines changed

9 files changed

+49
-27
lines changed

core/platform/android/libaxmol/axmol.gradle renamed to core/platform/android/dsl/axmol.gradle

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ class AxmolUtils {
138138
def symlinkDir = joinPath(sdkRoot, 'cmake', buildProfiles['cmakeVer'])
139139
def symlinkDirFile = new File(symlinkDir)
140140
if (!symlinkDirFile.exists()) {
141-
println "Creating symlinkd ${symlinkDir} ==> ${cmakeDir} ..."
142-
Files.createSymbolicLink(symlinkDirFile.toPath(), new File(cmakeDir).toPath())
141+
println "Creating symlink ${symlinkDir} ==> ${cmakeDir} ..."
142+
143+
def parentDir = symlinkDirFile.parentFile
144+
if(!parentDir.exists()) {
145+
parentDir.mkdirs()
146+
}
147+
148+
createSymbolicLink(symlinkDirFile, new File(cmakeDir))
143149
} else {
144150
println "The symlinkd ${symlinkDir} ==> ${cmakeDir} exist"
145151
}
@@ -326,6 +332,7 @@ class AxmolUtils {
326332
def foundCMakeVer = null
327333
def index = 0
328334
for(item in cmakeBinDirs) {
335+
println "find cmake in ${item}"
329336
foundCMakeVer = findCMakeFromBinDir(cmakeVer, item, allowNewerCMake)
330337
if(foundCMakeVer != null) {
331338
break
@@ -464,6 +471,19 @@ class AxmolUtils {
464471
private static boolean isWindows() {
465472
return System.getProperty("os.name").toLowerCase().contains("windows")
466473
}
474+
475+
static void createSymbolicLink(File linkDir, File targetDir) {
476+
if (isWindows()) {
477+
def command = ["cmd", "/c", "mklink", "/J", linkDir, targetDir]
478+
def proc = command.execute()
479+
proc.waitFor()
480+
if (proc.exitValue() != 0) {
481+
println "Create Junction fail: ${proc.err.text}"
482+
}
483+
} else {
484+
Files.createSymbolicLink(linkDir.toPath(), targetDir.toPath())
485+
}
486+
}
467487
}
468488

469489
ext.AxmolUtils = AxmolUtils

core/platform/android/libaxmol/axutils.gradle

Lines changed: 0 additions & 3 deletions
This file was deleted.

core/platform/android/libaxmol/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apply plugin: 'com.android.library'
2-
apply from: 'axmol.gradle'
2+
apply from: '../dsl/axmol.gradle'
33

44
def buildProfiles = AxmolUtils.resolveBasicBuildProfiles(project)
55

templates/common/proj.android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apply plugin: 'com.android.application'
2-
apply from: project(':libaxmol').projectDir.toString() + "/axmol.gradle"
2+
apply from: project(':libaxmol').projectDir.toString() + "/../dsl/axmol.gradle"
33

44
// Resolve build profiles
55
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)

tests/cpp-tests/proj.android/app/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
apply plugin: 'com.android.application'
2-
apply from: project(':libaxmol').projectDir.toString() + "/axutils.gradle"
2+
apply from: project(':libaxmol').projectDir.toString() + "/../dsl/axmol.gradle"
33

4-
android {
5-
// Resolve build profiles
6-
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
4+
// Resolve build profiles
5+
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
6+
7+
android {
78
def packageName = buildProfiles['packageName']
89
def cmakeVer = buildProfiles['cmakeVer']
910
def cmakeOptions = Eval.me(buildProfiles['cmakeOptions'])

tests/fairygui-tests/proj.android/app/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
apply plugin: 'com.android.application'
2-
apply from: project(':libaxmol').projectDir.toString() + "/axutils.gradle"
2+
apply from: project(':libaxmol').projectDir.toString() + "/../dsl/axmol.gradle"
33

4-
android {
5-
// Resolve build profiles
6-
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
4+
// Resolve build profiles
5+
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
6+
7+
android {
78
def packageName = buildProfiles['packageName']
89
def cmakeVer = buildProfiles['cmakeVer']
910
def cmakeOptions = Eval.me(buildProfiles['cmakeOptions'])

tests/live2d-tests/proj.android/app/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
apply plugin: 'com.android.application'
2-
apply from: project(':libaxmol').projectDir.toString() + "/axutils.gradle"
2+
apply from: project(':libaxmol').projectDir.toString() + "/../dsl/axmol.gradle"
33

4-
android {
5-
// Resolve build profiles
6-
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
4+
// Resolve build profiles
5+
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
6+
7+
android {
78
def packageName = buildProfiles['packageName']
89
def cmakeVer = buildProfiles['cmakeVer']
910
def cmakeOptions = Eval.me(buildProfiles['cmakeOptions'])

tests/lua-tests/proj.android/app/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
apply plugin: 'com.android.application'
2-
apply from: project(':libaxmol').projectDir.toString() + "/axutils.gradle"
2+
apply from: project(':libaxmol').projectDir.toString() + "/../dsl/axmol.gradle"
33

4-
android {
5-
// Resolve build profiles
6-
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
4+
// Resolve build profiles
5+
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
6+
7+
android {
78
def packageName = buildProfiles['packageName']
89
def cmakeVer = buildProfiles['cmakeVer']
910
def cmakeOptions = Eval.me(buildProfiles['cmakeOptions'])

tests/unit-tests/proj.android/app/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
apply plugin: 'com.android.application'
2-
apply from: project(':libaxmol').projectDir.toString() + "/axutils.gradle"
2+
apply from: project(':libaxmol').projectDir.toString() + "/../dsl/axmol.gradle"
33

4-
android {
5-
// Resolve build profiles
6-
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
4+
// Resolve build profiles
5+
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
6+
7+
android {
78
def packageName = buildProfiles['packageName']
89
def cmakeVer = buildProfiles['cmakeVer']
910
def cmakeOptions = Eval.me(buildProfiles['cmakeOptions'])

0 commit comments

Comments
 (0)