jni: Add all dependencies and their compilation scripts

Compilation has been verified for all target platforms using a slightly
modified version of CrystaX NDK 10.1.0 (the issue has been resolved with
not yet release 10.2.0)

Change-Id: I99f6c270ae8732adfa402d75ba04f42b179a1a9b
diff --git a/app/build.gradle b/app/build.gradle
index 9acf98e..df49097 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -59,7 +59,15 @@
 
     // call regular ndk-build(.cmd) script from app directory
     task ndkBuild(type: Exec) {
-        commandLine getNdkBuildCmd(), '-C', file('src/main').absolutePath
+        def ndkBuildParallel = Runtime.runtime.availableProcessors()
+        if (System.env.NDK_BUILD_PARALLEL != null) {
+            ndkBuildParallel = System.env.NDK_BUILD_PARALLEL
+        }
+        def ndkBuildAbi = "all"
+        if (System.env.NDK_BUILD_ABI != null) {
+           ndkBuildAbi = System.env.NDK_BUILD_ABI
+        }
+        commandLine getNdkBuildCmd(), '-C', file('src/main').absolutePath, '-j', ndkBuildParallel, "APP_ABI=" + ndkBuildAbi
     }
 
     tasks.withType(JavaCompile) {
@@ -74,17 +82,7 @@
 }
 
 def getNdkBuildCmd() {
-    if (System.env.ANDROID_NDK_ROOT != null)
-        return System.env.ANDROID_NDK_ROOT
-
-    Properties properties = new Properties()
-    properties.load(project.rootProject.file('local.properties').newDataInputStream())
-    String ndk_dir = properties.getProperty('ndk.dir', null)
-    if (ndk_dir == null) {
-        throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")
-    }
-
-    String ndk_build = ndk_dir + "/ndk-build"
+    def ndk_build = getNdkDir() + "/ndk-build"
     if (Os.isFamily(Os.FAMILY_WINDOWS)) {
         ndk_build += ".cmd"
     }
@@ -92,6 +90,19 @@
     return ndk_build
 }
 
+def getNdkDir() {
+    if (System.env.ANDROID_NDK_ROOT != null)
+        return System.env.ANDROID_NDK_ROOT
+
+    Properties properties = new Properties()
+    properties.load(project.rootProject.file('local.properties').newDataInputStream())
+    def ndk_dir = properties.getProperty('ndk.dir', null)
+    if (ndk_dir == null) {
+        throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")
+    }
+    return ndk_dir
+}
+
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'com.android.support:appcompat-v7:20.0.0'