summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorEder Bastos <bastos.eder@gmail.com>2015-05-18 20:22:01 -0400
committerEder Bastos <bastos.eder@gmail.com>2015-05-18 21:20:43 -0400
commit9c19d91e1815d71f74853434b5e8e34d8871b67a (patch)
tree6d227bb795406c9db44c0ee254b4983565158108 /Source/Android
parent7e6ec5fa869a9d62699639f6775ccccbd52b3c2a (diff)
Android: Allow building of native libraries inside Android Studio / Gradle
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/.gitignore3
-rw-r--r--Source/Android/app/build.gradle54
2 files changed, 56 insertions, 1 deletions
diff --git a/Source/Android/.gitignore b/Source/Android/.gitignore
index 78ddc4f68d..a053548512 100644
--- a/Source/Android/.gitignore
+++ b/Source/Android/.gitignore
@@ -39,4 +39,5 @@ tasks.xml
gradle/
build/
*.so
-*.iml \ No newline at end of file
+*.iml
+build.properties \ No newline at end of file
diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle
index ae34d82377..50ec4b23e0 100644
--- a/Source/Android/app/build.gradle
+++ b/Source/Android/app/build.gradle
@@ -41,6 +41,10 @@ android {
applicationIdSuffix ".debug"
versionNameSuffix '-debug'
jniDebuggable true
+
+ tasks.withType(JavaCompile) {
+ compileTask -> compileTask.dependsOn(compileNative)
+ }
}
}
}
@@ -58,3 +62,53 @@ dependencies {
// For loading huge screenshots from the disk.
compile 'com.squareup.picasso:picasso:2.5.2'
}
+
+task setupCMake(type: Exec) {
+ // Check if a build properties file exists.
+ def propsFile = rootProject.file("build.properties")
+
+ // If it does, call CMake.
+ if (propsFile.canRead()) {
+ // Read the properties file's contents.
+ def buildProperties = new Properties()
+ buildProperties.load(new FileInputStream(propsFile))
+
+ mkdir('build/' + buildProperties.abi)
+ workingDir 'build/' + buildProperties.abi
+
+ executable 'cmake'
+
+ args "-DANDROID=true",
+ "-DANDROID_NATIVE_API_LEVEL=android-18",
+ "-DCMAKE_TOOLCHAIN_FILE=../../../android.toolchain.cmake",
+ "../../../../..",
+ "-DGIT_EXECUTABLE=" + buildProperties.gitPath,
+ "-DANDROID_NDK=" + buildProperties.ndkPath,
+ "-DANDROID_TOOLCHAIN_NAME=" + buildProperties.toolchain,
+ "-DANDROID_ABI=" + buildProperties.abi
+ } else {
+ executable 'echo'
+ args 'No build.properties found; skipping CMake.'
+ }
+}
+
+task compileNative(type: Exec, dependsOn: 'setupCMake') {
+ // Check if a build properties file exists.
+ def propsFile = rootProject.file("build.properties")
+
+ // If it does, call make.
+ if (propsFile.canRead()) {
+ // Read the properties file's contents.
+ def buildProperties = new Properties()
+ buildProperties.load(new FileInputStream(propsFile))
+
+ workingDir 'build/' + buildProperties.abi
+
+ executable 'make'
+
+ args buildProperties.makeArgs
+ } else {
+ executable 'echo'
+ args 'No build.properties found; skipping native build.'
+ }
+} \ No newline at end of file