Android: Allow NDK location to be overridden

This commit is contained in:
Jeffrey Pfau
2015-06-12 19:59:25 -07:00
parent 4042945ee5
commit fff657a7da

View File

@ -161,6 +161,14 @@ String getGitPath() {
} }
String getNdkPath() { String getNdkPath() {
def propsFile = rootProject.file("build.properties")
def ndkPath = null
if (propsFile.canRead()) {
def buildProperties = new Properties()
buildProperties.load(new FileInputStream(propsFile))
ndkPath = buildProperties.ndkPath
}
if (ndkPath == null) {
try { try {
def stdout = new ByteArrayOutputStream() def stdout = new ByteArrayOutputStream()
@ -171,16 +179,16 @@ String getNdkPath() {
} }
def ndkCmdPath = stdout.toString() def ndkCmdPath = stdout.toString()
def ndkPath = ndkCmdPath.substring(0, ndkCmdPath.lastIndexOf('/')) ndkPath = ndkCmdPath.substring(0, ndkCmdPath.lastIndexOf('/'))
project.logger.quiet("Gradle: Found Android NDK:" + ndkPath)
return ndkPath
} catch (ignored) { } catch (ignored) {
project.logger.error("Gradle error: Couldn't find NDK.") project.logger.error("Gradle error: Couldn't find NDK.")
return null;
} }
} }
if (ndkPath != null) {
project.logger.quiet("Gradle: Found Android NDK: " + ndkPath)
}
return ndkPath
}
String getAbi() { String getAbi() {
String taskName = getGradle().startParameter.taskNames[0] String taskName = getGradle().startParameter.taskNames[0]