Skip to content

Commit

Permalink
[Android] Allow project to specify Axmol engine root path (#2361)
Browse files Browse the repository at this point in the history
* Use System.properties.AX_ROOT to store engine path
Allow Android builds to specify Axmol engine path

* If axmol folder exists in the root of the project folder, then use that for the engine path
  • Loading branch information
rh101 authored Feb 2, 2025
1 parent cbdef87 commit 166eeaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
14 changes: 11 additions & 3 deletions core/platform/android/libaxmol/axutils.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,19 @@ class AxmolUtils {
return buildProfiles
}

private static getEngineRoot() {
def axRoot = System.getProperty("AX_ROOT");
if (axRoot == null) {
axRoot = System.getenv("AX_ROOT");
}
return axRoot;
}

private static Properties loadProfiles(project, isAxmolAppProj) {
// build.profiles in axmol engine
def profiles = new Properties()
try {
profiles.load(new File(Paths.get("${System.env.AX_ROOT}/1k/build.profiles").toUri()).newDataInputStream())
profiles.load(new File(Paths.get("${getEngineRoot()}/1k/build.profiles").toUri()).newDataInputStream())
}
catch(ignored) {
}
Expand Down Expand Up @@ -311,7 +319,7 @@ class AxmolUtils {
cmakeBinDirs.add(cmakeBinDir)
}

cmakeBinDir = joinPath(Paths.get("${System.env.AX_ROOT}").toAbsolutePath().toString(), 'tools', 'external', 'cmake', 'bin')
cmakeBinDir = joinPath(Paths.get("${getEngineRoot()}").toAbsolutePath().toString(), 'tools', 'external', 'cmake', 'bin')
cmakeBinDirs.add(cmakeBinDir)

// find in cmakeBinDirs
Expand All @@ -327,7 +335,7 @@ class AxmolUtils {

if (index == (cmakeBinDirs.size() - 1)) {
// using cmakeBinDir=axmol/tools/external/cmake/bin
buildProfiles['cmakeDir'] = joinPath(Paths.get("${System.env.AX_ROOT}").toAbsolutePath().toString(), 'tools', 'external', 'cmake')
buildProfiles['cmakeDir'] = joinPath(Paths.get("${getEngineRoot()}").toAbsolutePath().toString(), 'tools', 'external', 'cmake')
}

if(foundCMakeVer == null) {
Expand Down
10 changes: 9 additions & 1 deletion templates/common/proj.android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import java.nio.file.Paths

def folder = new File("${settingsDir}/../axmol")
if (folder.exists()) {
System.setProperty("AX_ROOT", folder.path)
} else {
System.setProperty("AX_ROOT", "${System.env.AX_ROOT}")
}

include ':libaxmol'
project(':libaxmol').projectDir = new File(Paths.get("${System.env.AX_ROOT}/core/platform/android/libaxmol").toUri())
project(':libaxmol').projectDir = new File(Paths.get("${System.properties.AX_ROOT}/core/platform/android/libaxmol").toUri())
include ':Dummy'
project(':Dummy').projectDir = new File(settingsDir, 'app')
rootProject.name = "Dummy"

0 comments on commit 166eeaf

Please sign in to comment.