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
1 changed files with 26 additions and 18 deletions

View File

@ -161,25 +161,33 @@ String getGitPath() {
}
String getNdkPath() {
try {
def stdout = new ByteArrayOutputStream()
exec {
// ndk-build.cmd is a file unique to the root directory of android-ndk-r10e.
commandLine 'locate', 'ndk-build.cmd'
standardOutput = stdout
}
def ndkCmdPath = stdout.toString()
def ndkPath = ndkCmdPath.substring(0, ndkCmdPath.lastIndexOf('/'))
project.logger.quiet("Gradle: Found Android NDK:" + ndkPath)
return ndkPath
} catch (ignored) {
project.logger.error("Gradle error: Couldn't find NDK.")
return null;
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 {
def stdout = new ByteArrayOutputStream()
exec {
// ndk-build.cmd is a file unique to the root directory of android-ndk-r10e.
commandLine 'locate', 'ndk-build.cmd'
standardOutput = stdout
}
def ndkCmdPath = stdout.toString()
ndkPath = ndkCmdPath.substring(0, ndkCmdPath.lastIndexOf('/'))
} catch (ignored) {
project.logger.error("Gradle error: Couldn't find NDK.")
}
}
if (ndkPath != null) {
project.logger.quiet("Gradle: Found Android NDK: " + ndkPath)
}
return ndkPath
}
String getAbi() {