build.gradle 3.06 KB
Newer Older
1 2 3
apply plugin: 'com.android.library'

android {
4 5 6 7 8 9

    defaultConfig {
        compileSdkVersion rootProject.ext.compileSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        minSdkVersion rootProject.ext.minSdkVersion
    }
10 11 12

    sourceSets {
    main {
Edward Wang's avatar
Edward Wang committed
13
        jni.srcDirs = [] // Prevent gradle from building native code with ndk; we have our own Makefile for it.
14
        jniLibs.srcDirs = [ 'jni/libs' ] // Where generated .so files are placed.
15 16 17 18 19 20
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
21
        assets.srcDirs = ['assets' ]
22 23 24 25 26
    }
    }

    buildTypes {
        release {
27
            minifyEnabled false
28 29 30
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
31 32 33

    // Make per-variant version code
    libraryVariants.all { variant ->
Geoffrey Métais's avatar
Geoffrey Métais committed
34
        def vlcVersion = rootProject.ext.versionName
35
        //Custom APK name
Geoffrey Métais's avatar
Geoffrey Métais committed
36 37 38
        variant.outputs.each { output ->
            if (output.outputFileName != null && output.outputFileName.endsWith('.aar')) {
                output.outputFileName = "libvlc-${vlcVersion}.aar"
39 40 41
            }
        }
    }
42
}
43

44 45 46
/*
 * Include GDB files into apk
 */
47 48 49 50
//afterEvaluate {
//    Sync packageTask = project.getTasks().findByName("packageReleaseJniLibs")
//    packageTask.include(['**/gdbserver', '**/gdb.setup'])
//}
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
class BuildNative extends Exec {}

tasks.withType(BuildNative){
    /*
    Properties set for Android Studio own shell.
    when you run gradlew from cli, OS shell env variables will be used

    To be able to build from Android Studio, you have to set ndk.dir & sdk.dir
    properties in local.properties in the root folder, like this (for example):
    sdk.dir=/home/<username>/SDK/android-sdk-linux
    ndk.dir=/home/<username>/SDK/android-ndk-r10b
     */
    if (System.getenv('ANDROID_SDK') == null || System.getenv('ANDROID_NDK') == null) {
        Properties properties = new Properties()
        properties.load(project.rootProject.file('local.properties').newDataInputStream())
        environment 'ANDROID_NDK', properties.getProperty('ndk.dir')
        environment 'ANDROID_SDK', properties.getProperty('sdk.dir')
    }
    workingDir '..'
    commandLine './compile-libvlc.sh'
}

task buildDebugARMv7(type:BuildNative) {
    args('-a', "armeabi-v7a")
}
task buildDebugARM64(type:BuildNative) {
78
    args('-a', "arm64-v8a")
79 80 81 82 83 84 85 86 87 88 89 90 91
}
task buildDebugx86(type:BuildNative) {
    args('-a', "x86")
}
task buildDebugx86_64(type:BuildNative) {
    args('-a', "x86_64")
}
task buildDebugMIPS(type:BuildNative) {
    args('-a', "mips")
}
task buildDebugMIPS64(type:BuildNative) {
    args('-a', "mips64")
}
92 93 94 95 96 97

task generateSources (type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}

98 99 100 101
clean {
    delete 'build', 'jni/libs', 'jni/obj'
}

102
dependencies {
103 104
    api "androidx.annotation:annotation:$rootProject.ext.androidxVersion"
    api "androidx.legacy:legacy-support-v4:$rootProject.ext.androidxVersion"
105
}