summaryrefslogtreecommitdiff
path: root/platform/android/viewer/build.gradle
blob: 3d8088d2bd5c15ad78eb980cc363768073ac474f (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
buildscript {
	repositories {
		jcenter()
	}
	dependencies {
		classpath 'com.android.tools.build:gradle:1.2.3'
	}
}

allprojects {
	repositories {
		jcenter()
	}
}

apply plugin: 'com.android.application'

dependencies {
	compile fileTree(dir: 'libs', include: '*.so')
}

android {
	compileSdkVersion 17
	buildToolsVersion '21.1.2'

	/* this stops gradle from making it's own Android.mk file */
	sourceSets.main.jni.srcDirs = []

	sourceSets {
		main {
			manifest {
				srcFile 'AndroidManifest.xml'
			}
			java {
				srcDir 'src'
					exclude 'com/artifex/mupdf/fitz/AndroidDrawDevice.java'
			}
			res {
				srcDir 'res'
			}
			assets {
				srcDir 'assets'
			}
			resources {
				srcDir 'src'
			}
			jniLibs {
				srcDir 'libs'
			}
		}
	}

	/* This is important, it will run lint checks but won't abort build */
	lintOptions {
		abortOnError false
	}
}

//  This defines the path to Android's ndk-build.
import org.apache.tools.ant.taskdefs.condition.Os
def ndkBuildPath = plugins.getPlugin('com.android.application').sdkHandler.getNdkFolder().absolutePath + File.separator + 'ndk-build'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
	ndkBuildPath +='.cmd'
}

//  This task builds the native part
//  To build with experimental proofing enabled, define FZ_ENABLE_GPRF,
//  as shown below, and put a copy of libgs.so in the
//  JNI folder before building.

task buildNative(type: Exec,description: 'Compile JNI source via NDK') {
	println('executing buildNative')
//	commandLine ndkBuildPath, '-C', file('.').absolutePath, ' FZ_ENABLE_GPRF=1'
	commandLine ndkBuildPath, '-C', file('.').absolutePath
}

//  This task cleans the native part

task cleanNative(type: Exec, description: 'Clean JNI object files') {
	println('executing cleanNative')
	commandLine ndkBuildPath, '-C', file('.').absolutePath, 'clean'
}

//  cleaning should also include cleaning native

clean.dependsOn 'cleanNative'

//  building should include native

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