apply plugin: "com.android.application"

android {
    compileSdk 28

    defaultConfig {
        applicationId "net.sf.golly"
        minSdkVersion 21
        targetSdkVersion 35
        versionCode 6
        versionName "1.5"
        externalNativeBuild {
            cmake {

                // needed for std::string etc
                // also need System.loadLibrary("c++_shared") in BaseApp.java
                arguments "-DANDROID_STL=c++_shared"

                // define ANDROID_GUI used in the shared C++ code in gui-common;
                // define ZLIB so Golly can read/write .gz files;
                // set -fexceptions so we can use stdexcept
                cppFlags "-DANDROID_GUI", "-DZLIB", "-fexceptions", "-Wno-c++11-narrowing"
            }
        }
    }

    buildTypes {
        debug {
            ndk {
                debuggable true
            }
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile("proguard-android.txt")
            ndk {
                debuggable false
            }
        }
    }

    externalNativeBuild {
        cmake {
            path 'CMakeLists.txt'
        }
    }

    namespace "net.sf.golly"

    ndkVersion "26.3.11579264"
}

dependencies {
    implementation "com.android.support:support-fragment:28.0.0"
}

task zipHelp(type: Zip) {
    archiveFileName = "Help.zip"
    from "../../../gui-common/Help"
    include "**/*"
    into "Help"
    destinationDirectory = file("src/main/assets/")
}

task zipPatterns(type: Zip) {
    archiveFileName = "Patterns.zip"
    from "../../../Patterns"
    // include "**/*"
    // avoid including *.rle3/zip/lua files:
    include "**/*.rle", "**/*.rle.gz", "**/*.mc", "**/*.mc.gz", "**/*.mcl", "**/*.lif"
    into "Patterns"
    destinationDirectory = file("src/main/assets/")
}

task zipRules(type: Zip) {
    archiveFileName = "Rules.zip"
    from "../../../Rules"
    include "**/*"
    into "Rules"
    destinationDirectory = file("src/main/assets/")
}

preBuild.dependsOn(zipHelp)
preBuild.dependsOn(zipPatterns)
preBuild.dependsOn(zipRules)
