
plugins {
    id 'com.android.library'
    id 'kotlin-android'
}

android {
    namespace = "com.alimin.fk"
    compileSdkVersion Integer.parseInt(target_version)

    defaultConfig {
        minSdkVersion Integer.parseInt(min_version)
        targetSdkVersion Integer.parseInt(target_version)
        versionCode Integer.parseInt(version_code)
        versionName version_name
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        flavorDimensions "version"
        externalNativeBuild {
            cmake {
                arguments "-DANDROID_ARM_NEON=TRUE",
                        "-DANDROID_CPP_FEATURES=rtti exceptions",
                        "-DENABLE_FK=TRUE",
                        "-DOPTIMIZE_CLASS_TYPE=TRUE",
                        "-DANDROID_ARM_NEON=ON",
                        "-DENABLE_SKIA_SRC=OFF"
            }
        }
        ndk {
            stl "libstdc++"
            abiFilters "arm64-v8a"
//            abiFilters "armeabi-v7a", "arm64-v8a"
        }
        sourceSets.main {
            jni.srcDirs = []
            jniLibs.srcDirs = ["../../../src/third_party/protobuf/shared",
                               "../../../src/third_party/skia/shared"]
        }
        buildConfigField("boolean", "ENABLE_UNIT_TEST", "false")
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField("boolean", "ENABLE_UNIT_TEST", "false")
            externalNativeBuild {
                cmake {
//                    cppFlags "-fprofile-arcs -ftest-coverage --coverage -fprofile-instr-generate"
                    arguments.add "-DENABLE_G_TEST=FALSE"
                }
            }
        }
        debug {
            buildConfigField("boolean", "ENABLE_UNIT_TEST", "true")
            externalNativeBuild {
                cmake {
//                    cppFlags "-fprofile-arcs -ftest-coverage --coverage -fprofile-instr-generate"
                    arguments.add "-DENABLE_G_TEST=TRUE"
                }
            }
        }
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
//            version "3.10.2.4988404"
        }
    }
    android.libraryVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "film_kilns_${defaultConfig.versionName}_${defaultConfig.versionCode}" + '.aar'
        }
    }
    buildFeatures {
        compose = false
        buildConfig true
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test:core:1.5.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    implementation "androidx.appcompat:appcompat:$androidx_version"
    implementation "androidx.core:core-ktx:$androidx_version"
    api 'com.google.protobuf:protobuf-java:3.19.4'
}