summaryrefslogtreecommitdiffstats
path: root/android/xscreensaver/build.gradle
blob: 038e613786c85e5134af9e2b0b9a7ec45e107820 (plain) (blame)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
apply plugin: 'android'

dependencies {
    implementation fileTree(include: '*.jar', dir: 'libs')
    implementation "com.android.support:support-v4:27.1.1"
}

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            // jniLibs.srcDirs = ['jni']
            jniLibs.srcDirs = ['libs']
            jni.srcDirs = [] // disable automatic ndk-build call
        }

        // Move the tests to tests/java, tests/res, etc...
        androidTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
    //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*


    // put ndk-build in build's path, or replace below with its full path
    task ndkBuild(type: Exec) {
       Properties properties = new Properties()
         properties.load(project.rootProject.file('local.properties').newDataInputStream())
       def ndkDir = properties.getProperty('ndk.dir')
       commandLine "$ndkDir/ndk-build", '-C', file('jni').absolutePath,
          '-j' + Runtime.getRuntime().availableProcessors().toString()
    }

    // generate files early in the process
    task perlBuild(type: Exec) {
        commandLine 'sh', '-c',
          'cd ..; ../hacks/check-configs.pl --build-android $ANDROID_HACKS'
    }
  
    task perlClean(type: Delete) {
        delete('../gen')
        delete('res/values')
        delete('res/xml')
        delete('src/org/jwz/xscreensaver/gen')
        delete('AndroidManifest.xml')
    }

    task objlibClean(type: Delete) {
        delete('./build')
        delete('./libs')
        delete('./obj')
    }

    task downloadNeededDrawables(type: Exec) {
        commandLine 'sh', '-c',
          'cd ../ ; \
           for f in $ANDROID_HACKS; do \
	     f=`echo "$f" | sed s/rd-bomb/rdbomb/` ; \
             make -s xscreensaver/res/drawable/$f.png ; \
           done'
    }
    preBuild.dependsOn downloadNeededDrawables

    preBuild.dependsOn perlBuild

    clean.dependsOn perlClean
    clean.dependsOn objlibClean

    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
    }

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


    defaultConfig {
        // Previous applicationId was "org.jwz.xscreensaver" but I had
        // to change it because I managed to lose the signing key...
        // Note that the Java class tree is still "org.jwz.xscreensaver".
        applicationId "org.jwz.android.xscreensaver"
        minSdkVersion 15
        targetSdkVersion 27
    }
    productFlavors {
    }
    buildTypes {
        debug {
            jniDebuggable true
        }
    }
}