diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2015-06-13 13:56:53 -0500 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2015-06-13 13:56:53 -0500 |
| commit | c981f6407eb118ae39caf4dc6aa10eddc285d85e (patch) | |
| tree | f586f41f17544eddee9f3e6b704c9bcd6d4c4e1a /Source/Android | |
| parent | 1c1282fddc420de7c7bdbbd7b402277bc68d3ba9 (diff) | |
| parent | dfae4e62669c6effeae949d239e8f1206b0e5360 (diff) | |
Merge pull request #2597 from endrift/android-allow-ndk-override
Android: Allow NDK location to be specified manually
Diffstat (limited to 'Source/Android')
| -rw-r--r-- | Source/Android/app/build.gradle | 83 |
1 files changed, 50 insertions, 33 deletions
diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index 8f7134c290..6c1a46a914 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -101,13 +101,13 @@ task setupCMake(type: Exec) { mkdir('build/' + abi) workingDir 'build/' + abi - executable 'cmake' + executable getExecutablePath("cmake") args "-DANDROID=true", "-DANDROID_NATIVE_API_LEVEL=android-18", "-DCMAKE_TOOLCHAIN_FILE=../../../android.toolchain.cmake", "../../../../..", - "-DGIT_EXECUTABLE=" + getGitPath(), + "-DGIT_EXECUTABLE=" + getExecutablePath("git"), "-DANDROID_NDK=" + getNdkPath(), "-DANDROID_TOOLCHAIN_NAME=" + getToolchainName(), "-DANDROID_ABI=" + abi @@ -140,46 +140,63 @@ task compileNative(type: Exec, dependsOn: 'setupCMake') { } } -String getGitPath() { - try { - def stdout = new ByteArrayOutputStream() - - exec { - commandLine 'which', 'git' - standardOutput = stdout - } +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 { + def stdout = new ByteArrayOutputStream() - def gitPath = stdout.toString().trim() - project.logger.quiet("Gradle: Found git executuable:" + gitPath) + exec { + commandLine 'which', command + standardOutput = stdout + } - return gitPath - } catch (ignored) { - // Shouldn't happen. How did the user get this file without git? - project.logger.error("Gradle error: Couldn't find git executable.") - return null; + path = stdout.toString().trim() + } catch (ignored) { + project.logger.error("Gradle error: Couldn't find " + command + " executable.") + } + } + if (path != null) { + project.logger.quiet("Gradle: Found " + command + " executuable:" + path) } + return path } String getNdkPath() { - try { - def stdout = new ByteArrayOutputStream() + 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 + } - 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.") } - - 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; } + if (ndkPath != null) { + project.logger.quiet("Gradle: Found Android NDK: " + ndkPath) + } + return ndkPath } String getAbi() { |
