Skip to content

Commit

Permalink
Use ndkBuild in Gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
Robyer committed Jan 9, 2019
1 parent 531b275 commit 572c2f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 58 deletions.
36 changes: 6 additions & 30 deletions eyes-two/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}

}

Expand Down
33 changes: 5 additions & 28 deletions tess-two/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
}

Expand Down

0 comments on commit 572c2f1

Please sign in to comment.