diff --git a/build.gradle b/build.gradle index c3890f28..14cc5431 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,26 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } + sourceSets.main { + jniLibs.srcDir 'src/main/libs' //set .so files location to libs + jni.srcDirs = [] //disable automatic ndk-build call + } + + task buildNative(type: Exec) { + def ndkDir = android.ndkDirectory + commandLine "$ndkDir/ndk-build", + '-C', file('src/main/jni').absolutePath, + '-j', Runtime.runtime.availableProcessors(), + 'all', + 'NDK_DEBUG=1' + } + + task cleanNative(type: Exec) { + def ndkDir = android.ndkDirectory + commandLine "$ndkDir/ndk-build", + '-C', file('src/main/jni').absolutePath, + 'clean' + } defaultConfig { minSdkVersion 8 targetSdkVersion 22 @@ -36,21 +56,26 @@ android { } } } - buildTypes.debug.jniDebuggable isDebugBuild() +// buildTypes.debug.jniDebuggable isDebugBuild() +// +// if (shouldApplyFlavors()) { +// productFlavors { +// flavors.each() { +// String flavor = it +// "${it}" { +// ndk { +// abiFilter flavor +// } +// } +// } +// fat +// } +// } +} +clean.dependsOn cleanNative - if (shouldApplyFlavors()) { - productFlavors { - flavors.each() { - String flavor = it - "${it}" { - ndk { - abiFilter flavor - } - } - } - fat - } - } +tasks.withType(JavaCompile) { + compileTask -> compileTask.dependsOn buildNative } allprojects { diff --git a/src/main/jni/Android.mk b/src/main/jni/Android.mk new file mode 100644 index 00000000..db2f2332 --- /dev/null +++ b/src/main/jni/Android.mk @@ -0,0 +1,39 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := pl_droidsonroids_gif +LOCAL_CFLAGS := -Ofast -DDEBUG +LOCAL_LDLIBS := \ + -ljnigraphics \ + -llog \ + +LOCAL_SRC_FILES := \ + drawing.c \ + gif.c \ + metadata.c \ + memset32_neon.S \ + bitmap.c \ + open_close.c \ + decoding.c \ + exception.c \ + time.c \ + control.c \ + memset.arm.S \ + giflib/dgif_lib.c \ + giflib/gifalloc.c \ + + +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_MODULE := pl_droidsonroids_gif_surface +LOCAL_CFLAGS := -Ofast -DDEBUG +LOCAL_LDLIBS := \ + -landroid \ + -llog \ + +LOCAL_SRC_FILES := \ + surface.c \ + +include $(BUILD_SHARED_LIBRARY) diff --git a/src/main/jni/Application.mk b/src/main/jni/Application.mk new file mode 100644 index 00000000..70a6692a --- /dev/null +++ b/src/main/jni/Application.mk @@ -0,0 +1,5 @@ +APP_ABI := all +APP_PLATFORM := android-21 +APP_OPTIM := debug + +#NDK_TOOLCHAIN_VERSION := clang \ No newline at end of file