Android: No longer require specification of NDK or Git paths in build.gradle.

This commit is contained in:
Eder Bastos 2015-05-19 09:05:35 -04:00
parent 9c19d91e18
commit 4cded65320
2 changed files with 47 additions and 8 deletions

View File

@ -55,21 +55,18 @@ the Android UI. Import the Gradle project located in `./Source/Android`, and the
Gradle task `assembleDebug` to build, or `installDebug` to install the UI onto a connected device. Gradle task `assembleDebug` to build, or `installDebug` to install the UI onto a connected device.
In order to launch the app, you must build and include the native Dolphin libraries into the UI project. In order to launch the app, you must build and include the native Dolphin libraries into the UI project.
Building native code requires the [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html). (Building native code requires the [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html).)
Android Studio will do this for you if you create `Source/Android/build.properties`, and place the Android Studio will do this for you if you create `Source/Android/build.properties`, and place the
following inside: following inside:
``` ```
gitPath=<git-path>
ndkPath=<ndk-path>
toolchain=<toolchain> toolchain=<toolchain>
abi=<abi> abi=<abi>
makeArgs=<make-args> makeArgs=<make-args>
``` ```
Replace `<git-path>` with the absolute path to your machine's Git executable, `<ndk-path>` with the absolute Replace `<make-args>` with any arguments you want to pass to `make`, and the rest depending on which
path to where you installed your NDK, `<make-args>` with any arguments you want to pass to `make`, and the platform the Android device you are targeting uses:
rest depending on which platform the Android device you are targeting uses:
|Platform | `<abi>` | `<toolchain>` | |Platform | `<abi>` | `<toolchain>` |
|-------------------------|-------------|---------------------------| |-------------------------|-------------|---------------------------|

View File

@ -82,8 +82,8 @@ task setupCMake(type: Exec) {
"-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=" + buildProperties.gitPath, "-DGIT_EXECUTABLE=" + getGitPath(),
"-DANDROID_NDK=" + buildProperties.ndkPath, "-DANDROID_NDK=" + getNdkPath(),
"-DANDROID_TOOLCHAIN_NAME=" + buildProperties.toolchain, "-DANDROID_TOOLCHAIN_NAME=" + buildProperties.toolchain,
"-DANDROID_ABI=" + buildProperties.abi "-DANDROID_ABI=" + buildProperties.abi
} else { } else {
@ -111,4 +111,46 @@ task compileNative(type: Exec, dependsOn: 'setupCMake') {
executable 'echo' executable 'echo'
args 'No build.properties found; skipping native build.' args 'No build.properties found; skipping native build.'
} }
}
String getGitPath() {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'which', 'git'
standardOutput = stdout
}
def gitPath = stdout.toString().trim()
project.logger.quiet("Gradle: Found git executuable:" + gitPath)
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;
}
}
String getNdkPath() {
try {
def stdout = new ByteArrayOutputStream()
exec {
// ndk-build.cmd is a file unique to the root directory of android-ndk-r10d.
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;
}
} }