apply plugin: 'com.android.model.native'

model {
    android {
        compileSdkVersion = gradle.sdkVersion
        buildToolsVersion = gradle.buildToolsVersion

        defaultConfig {
            minSdkVersion.apiLevel = gradle.minSdkVersion
            versionCode = 1
            versionName = '1.0'
        }
        ndk {
            moduleName = 'SDL2_jpeg'
            ldLibs.addAll(["GLESv1_CM", "EGL", "GLESv2", "log", "android", "dl", "z"])
            CFlags.addAll([
                           "-DGL_GLEXT_PROTOTYPES"
            ])
            CFlags.addAll(["-I" + file("include/").absolutePath,"-DGL_GLEXT_PROTOTYPES"])
        }

        sources {
            main {
                jni {
                    source {
                        srcDir "src"
                        exclude "cjpeg.c"
                        exclude "ckconfig.c"
                        exclude "djpeg.c"
                        exclude "example.c"
                        exclude "jmemansi.c"
                        exclude "jmemdos.c"
                        exclude "jmemmac.c"
                        exclude "jmemname.c"
                        exclude "jmemnobs.c"
                        exclude "jpegtran.c"
                        exclude "rdjpgcom.c"
                    }
                }
            }
        }

    }
}

task(distributeLib, type : Copy) {
    // trigger build library
    dependsOn assemble
    into gradle.libDistributionRoot + '/SDL2_jpeg/'
    from('build/outputs/native/release/lib') {
        into 'lib/'
    }
}
