From http://www.jwz.org/xscreensaver/xscreensaver-5.33.tar.gz
[xscreensaver] / android / project / xscreensaver / build.gradle
1 apply plugin: 'android'
2
3 dependencies {
4     compile fileTree(include: '*.jar', dir: 'libs')
5     compile project(':GLWallpaperService')
6 }
7
8 android {
9     compileSdkVersion 21
10     buildToolsVersion "21.1.2"
11     compileOptions {
12         sourceCompatibility JavaVersion.VERSION_1_7
13         targetCompatibility JavaVersion.VERSION_1_7
14     }
15     sourceSets {
16         main {
17             manifest.srcFile 'AndroidManifest.xml'
18             java.srcDirs = ['src']
19             resources.srcDirs = ['src']
20             aidl.srcDirs = ['src']
21             renderscript.srcDirs = ['src']
22             res.srcDirs = ['res']
23             assets.srcDirs = ['assets']
24             // jniLibs.srcDirs = ['jni']
25             jniLibs.srcDirs = ['libs']
26             jni.srcDirs = [] // disable automatic ndk-build call
27         }
28
29         // Move the tests to tests/java, tests/res, etc...
30         instrumentTest.setRoot('tests')
31
32         // Move the build types to build-types/<type>
33         // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
34         // This moves them out of them default location under src/<type>/... which would
35         // conflict with src/ being used by the main source set.
36         // Adding new build types or product flavors should be accompanied
37         // by a similar customization.
38         debug.setRoot('build-types/debug')
39         release.setRoot('build-types/release')
40     }
41     project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
42     //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*
43
44
45     // put ndk-build in build's path, or replace below with its full path
46     task ndkBuild(type: Exec) {
47        Properties properties = new Properties()
48          properties.load(project.rootProject.file('local.properties').newDataInputStream())
49        def ndkDir = properties.getProperty('ndk.dir')
50        commandLine "$ndkDir/ndk-build", '-C', file('jni').absolutePath
51     }
52
53     // generate files early in the process
54     task perlBuild(type: Exec) {
55         commandLine 'perl', '-x../..', '../../generate_files.pl', 'sproingies', 'superquadrics', 'stonerview', 'unknownpleasures', 'bouncingcow', 'hypertorus', 'glhanoi'
56     }
57
58   
59     task perlClean(type: Exec) {
60         commandLine 'rm', '-f', '../../gen/glue.c', './res/values/items.xml', './res/values/strings.xml', './res/values/settings.xml'
61     }
62
63     task perlCleaner(type: Exec) {
64         commandLine 'rm', '-rf', './res/xml', './src/org/jwz/xscreensaver/gen'
65     }
66
67     task objlibClean(type: Exec) {
68         commandLine 'rm', '-rf', './obj/local', './libs/armeabi', './libs/armeabi-v7a', './libs/mips', './libs/x86'
69     }
70
71  
72     // if perlBuild already generated file, do not run perlBuild again
73     if (! file("../../gen/glue.c").exists()) {
74         preBuild.dependsOn perlBuild
75     }
76
77     clean.dependsOn perlClean
78     clean.dependsOn perlCleaner
79     clean.dependsOn objlibClean
80
81     // 
82     tasks.withType(JavaCompile) {
83         compileTask -> compileTask.dependsOn ndkBuild
84     }
85
86
87     defaultConfig {
88         minSdkVersion 15
89         targetSdkVersion 21
90     }
91     productFlavors {
92     }
93     buildTypes {
94         debug {
95             jniDebuggable true
96         }
97     }
98 }