From fff657a7dac67dfe7e1ba98132bf9fa11a310634 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 12 Jun 2015 19:59:25 -0700 Subject: [PATCH] Android: Allow NDK location to be overridden --- Source/Android/app/build.gradle | 44 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index 8f7134c290..c7d41a9082 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -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() {