6d1151ff1016792efdd3ea96d84aa81e287e9a13
[xscreensaver] / android / xscreensaver / build.gradle
1 apply plugin: 'android'
2
3 dependencies {
4     compile fileTree(include: '*.jar', dir: 'libs')
5 }
6
7 android {
8     compileSdkVersion 21
9     buildToolsVersion "21.1.2"
10     compileOptions {
11         sourceCompatibility JavaVersion.VERSION_1_7
12         targetCompatibility JavaVersion.VERSION_1_7
13     }
14     sourceSets {
15         main {
16             manifest.srcFile 'AndroidManifest.xml'
17             java.srcDirs = ['src']
18             resources.srcDirs = ['src']
19             aidl.srcDirs = ['src']
20             renderscript.srcDirs = ['src']
21             res.srcDirs = ['res']
22             assets.srcDirs = ['assets']
23             // jniLibs.srcDirs = ['jni']
24             jniLibs.srcDirs = ['libs']
25             jni.srcDirs = [] // disable automatic ndk-build call
26         }
27
28         // Move the tests to tests/java, tests/res, etc...
29         instrumentTest.setRoot('tests')
30
31         // Move the build types to build-types/<type>
32         // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
33         // This moves them out of them default location under src/<type>/... which would
34         // conflict with src/ being used by the main source set.
35         // Adding new build types or product flavors should be accompanied
36         // by a similar customization.
37         debug.setRoot('build-types/debug')
38         release.setRoot('build-types/release')
39     }
40     project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
41     //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*
42
43
44     // put ndk-build in build's path, or replace below with its full path
45     task ndkBuild(type: Exec) {
46        Properties properties = new Properties()
47          properties.load(project.rootProject.file('local.properties').newDataInputStream())
48        def ndkDir = properties.getProperty('ndk.dir')
49        commandLine "$ndkDir/ndk-build", '-C', file('jni').absolutePath,
50           '-j' + Runtime.getRuntime().availableProcessors().toString()
51     }
52
53     // generate files early in the process
54     task perlBuild(type: Exec) {
55         commandLine 'sh', '-c',
56           'cd ..; ../hacks/check-configs.pl --build-android $ANDROID_HACKS'
57     }
58   
59     task perlClean(type: Delete) {
60         delete('../gen')
61         delete('res/values')
62         delete('res/xml')
63         delete('src/org/jwz/xscreensaver/gen')
64         delete('AndroidManifest.xml')
65     }
66
67     task objlibClean(type: Delete) {
68         delete('./build')
69         delete('./libs')
70         delete('./obj')
71     }
72
73     task downloadNeededDrawables(type: Exec) {
74         commandLine 'sh', '-c',
75           'cd ../ ; \
76            for f in $ANDROID_HACKS; do \
77              f=`echo "$f" | sed s/rd-bomb/rdbomb/` ; \
78              make -s xscreensaver/res/drawable/$f.png ; \
79            done'
80     }
81     preBuild.dependsOn downloadNeededDrawables
82
83     preBuild.dependsOn perlBuild
84
85     clean.dependsOn perlClean
86     clean.dependsOn objlibClean
87
88     tasks.withType(JavaCompile) {
89         options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
90     }
91
92     tasks.withType(JavaCompile) {
93         compileTask -> compileTask.dependsOn ndkBuild
94     }
95
96
97     defaultConfig {
98         minSdkVersion 15
99         targetSdkVersion 21
100     }
101     productFlavors {
102     }
103     buildTypes {
104         debug {
105             jniDebuggable true
106         }
107     }
108 }