Skip to content

Commit

Permalink
Android studio migration: NDK integration into gradle. Get rid of com…
Browse files Browse the repository at this point in the history
…mitted binaries.
  • Loading branch information
Vilbrekin committed Jan 15, 2015
1 parent 202937d commit 22d0378
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ app/manifest-merger-release-report.txt
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids

app/src/main/obj/
app/src/main/libs/
1 change: 0 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
Expand Down
29 changes: 29 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {
Expand All @@ -18,6 +20,33 @@ android {
}
}

sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}

def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
def nkdBuildCmd = "$ndkDir/ndk-build" + (Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : "")
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {

commandLine "$nkdBuildCmd",
'-C', file('src/main/jni').absolutePath,
'-j', Runtime.runtime.availableProcessors(),
'all'
}

task cleanNative(type: Exec, description: 'Clean JNI object files') {
commandLine "$nkdBuildCmd",
'-C', file('src/main/jni').absolutePath,
'clean'
}

clean.dependsOn 'cleanNative'

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}

buildTypes {
release {
minifyEnabled false
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/armeabi
2 changes: 1 addition & 1 deletion app/src/main/assets/mips
2 changes: 1 addition & 1 deletion app/src/main/assets/x86
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LOCAL_CFLAGS := -std=gnu99 -DHAVE_CONFIG_H -DCONFDIR=\"/etc\" -DLOCALSTATEDIR=\"
LOCAL_STATIC_LIBRARIES := libcrypto_static libssl_static
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_SRC_FILES += tinc/src/protocol_edge.c tinc/src/xmalloc.c tinc/src/dummy_device.c tinc/src/protocol_subnet.c tinc/src/edge.c tinc/src/pidfile.c tinc/src/conf.c tinc/src/protocol_misc.c tinc/src/utils.c tinc/src/event.c tinc/src/protocol_key.c tinc/src/raw_socket_device.c tinc/src/protocol.c tinc/src/net_socket.c tinc/src/logger.c tinc/src/list.c tinc/src/fake-getaddrinfo.c tinc/src/net.c tinc/src/tincd.c tinc/src/graph.c tinc/src/process.c tinc/src/net_packet.c tinc/src/netutl.c tinc/src/linux/device.c tinc/src/avl_tree.c tinc/src/route.c tinc/src/meta.c tinc/src/protocol_auth.c tinc/src/net_setup.c tinc/src/getopt.c tinc/src/multicast_device.c tinc/src/connection.c tinc/src/subnet.c tinc/src/node.c tinc/src/fake-getnameinfo.c tinc/src/getopt1.c tinc/src/dropin.c
OPENSSL_DIR := $(NDK_PROJECT_PATH)/platform_external_openssl
OPENSSL_DIR := $(NDK_PROJECT_PATH)/jni/platform_external_openssl
LOCAL_C_INCLUDES := $(OPENSSL_DIR)/include

# Hack around missing #ifdef HAVE_CONFIG_H in system.h and relative paths includes (so that it finds ../config.h file)
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions app/src/main/jni/platform_external_openssl
1 change: 1 addition & 0 deletions app/src/main/jni/tinc/config.h
File renamed without changes.
Binary file removed app/src/main/jnilibs/armeabi/tincd
Binary file not shown.
Binary file removed app/src/main/jnilibs/mips/tincd
Binary file not shown.
Binary file removed app/src/main/jnilibs/x86/tincd
Binary file not shown.
Binary file removed build/intermediates/model_data.bin
Binary file not shown.

0 comments on commit 22d0378

Please sign in to comment.