Android: Allow git and cmake locations to be overridden

This commit is contained in:
Jeffrey Pfau
2015-06-13 03:54:37 -07:00
parent fff657a7da
commit 7e36166374

View File

@ -101,13 +101,13 @@ task setupCMake(type: Exec) {
mkdir('build/' + abi) mkdir('build/' + abi)
workingDir 'build/' + abi workingDir 'build/' + abi
executable 'cmake' executable getExecutablePath("cmake")
args "-DANDROID=true", args "-DANDROID=true",
"-DANDROID_NATIVE_API_LEVEL=android-18", "-DANDROID_NATIVE_API_LEVEL=android-18",
"-DCMAKE_TOOLCHAIN_FILE=../../../android.toolchain.cmake", "-DCMAKE_TOOLCHAIN_FILE=../../../android.toolchain.cmake",
"../../../../..", "../../../../..",
"-DGIT_EXECUTABLE=" + getGitPath(), "-DGIT_EXECUTABLE=" + getExecutablePath("git"),
"-DANDROID_NDK=" + getNdkPath(), "-DANDROID_NDK=" + getNdkPath(),
"-DANDROID_TOOLCHAIN_NAME=" + getToolchainName(), "-DANDROID_TOOLCHAIN_NAME=" + getToolchainName(),
"-DANDROID_ABI=" + abi "-DANDROID_ABI=" + abi
@ -140,25 +140,34 @@ task compileNative(type: Exec, dependsOn: 'setupCMake') {
} }
} }
String getGitPath() { String getExecutablePath(String command) {
def propsFile = rootProject.file("build.properties")
def path = null
if (propsFile.canRead()) {
def buildProperties = new Properties()
buildProperties.load(new FileInputStream(propsFile))
println buildProperties
path = buildProperties[command + "Path"]
}
if (path == null) {
try { try {
def stdout = new ByteArrayOutputStream() def stdout = new ByteArrayOutputStream()
exec { exec {
commandLine 'which', 'git' commandLine 'which', command
standardOutput = stdout standardOutput = stdout
} }
def gitPath = stdout.toString().trim() path = stdout.toString().trim()
project.logger.quiet("Gradle: Found git executuable:" + gitPath)
return gitPath
} catch (ignored) { } catch (ignored) {
// Shouldn't happen. How did the user get this file without git? project.logger.error("Gradle error: Couldn't find " + command + " executable.")
project.logger.error("Gradle error: Couldn't find git executable.")
return null;
} }
} }
if (path != null) {
project.logger.quiet("Gradle: Found " + command + " executuable:" + path)
}
return path
}
String getNdkPath() { String getNdkPath() {
def propsFile = rootProject.file("build.properties") def propsFile = rootProject.file("build.properties")