-
Notifications
You must be signed in to change notification settings - Fork 2
/
curl.gradle
74 lines (65 loc) · 1.97 KB
/
curl.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
apply plugin: 'com.android.application'
android {
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir 'jni/jniLibsCurl' // This is not necessary unless you have precompiled libraries in your project.
}
defaultConfig {
ndk {
moduleName "curl-prebuilt"
}
}
buildTypes
{
release
{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors
{
arm
{
ndk
{
abiFilters "armeabi"
}
}
x86
{
ndk
{
abiFilter "x86"
}
}
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = System.getenv('ANDROID_NDK_HOME')
if (ndkDir == null) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
ndkDir = properties.getProperty('ndk.dir')?:null
}
commandLine "$ndkDir/ndk-build",
'-C', file('jni').absolutePath, // Change src/jni the relative path to your jni source
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = System.getenv('ANDROID_NDK_HOME')
if (ndkDir == null) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
ndkDir = properties.getProperty('ndk.dir')?:null
}
commandLine "$ndkDir/ndk-build",
'-C', file('jni').absolutePath, // Change src/jni the relative path to your jni source
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}