From 572c2f1a12a298728b98acb6d87846ddc7de26f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Mon, 7 Jan 2019 18:33:35 +0100 Subject: [PATCH] Use ndkBuild in Gradle --- eyes-two/build.gradle | 36 ++++++------------------------------ tess-two/build.gradle | 33 +++++---------------------------- 2 files changed, 11 insertions(+), 58 deletions(-) diff --git a/eyes-two/build.gradle b/eyes-two/build.gradle index 14300ce2e..d53f8b8fd 100644 --- a/eyes-two/build.gradle +++ b/eyes-two/build.gradle @@ -18,43 +18,19 @@ android { sourceSets { main { - jni.srcDirs = [] + jni.srcDirs = ['src/main/jni'] jniLibs.srcDirs = ['src/main/libs'] } } - // Call external ndk-build(.cmd) script to build the native code - task ndkBuild(type: Exec) { - def ndkDirProperty = properties.getProperty('ndk.dir') - def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : '' - - def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : '' - - commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('src/main').absolutePath, - '-j', Runtime.runtime.availableProcessors() - } - - tasks.withType(JavaCompile) { - compileTask -> compileTask.dependsOn ndkBuild - } - - // Cleanup task to remove previously generated binaries - task ndkClean(type: Exec) { - def ndkDirProperty = properties.getProperty('ndk.dir') - def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : '' - - def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : '' - - commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}",'-C', file('src/main').absolutePath, 'clean' - } - - tasks.withType(Delete) { - cleanTask -> cleanTask.dependsOn ndkClean - } - lintOptions { abortOnError false } + externalNativeBuild { + ndkBuild { + path file('src/main/jni/Android.mk') + } + } } diff --git a/tess-two/build.gradle b/tess-two/build.gradle index 7a12c4dd0..7ebddc305 100644 --- a/tess-two/build.gradle +++ b/tess-two/build.gradle @@ -24,38 +24,15 @@ android { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] res.srcDirs = ['res'] - jni.srcDirs = [] + jni.srcDirs = ['jni'] jniLibs.srcDirs = ['libs'] } } - // Call external ndk-build(.cmd) script to build the native code - task ndkBuild(type: Exec) { - def ndkDirProperty = properties.getProperty('ndk.dir') - def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : '' - - def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : "" - - commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath, - '-j', Runtime.runtime.availableProcessors() - } - - tasks.withType(JavaCompile) { - compileTask -> compileTask.dependsOn ndkBuild - } - - // Cleanup task to remove previously generated binaries - task ndkClean(type: Exec) { - def ndkDirProperty = properties.getProperty('ndk.dir') - def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : '' - - def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : "" - - commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath, 'clean' - } - - tasks.withType(Delete) { - cleanTask -> cleanTask.dependsOn ndkClean + externalNativeBuild { + ndkBuild { + path file('jni/Android.mk') + } } }