apply plugin: 'com.android.library'
apply from: '../module.gradle'
apply from: '../upload.gradle'

if (project.COMPILE_JS_ENGINE == 'All') {
    apply from: 'fetch_jsc_libs.gradle'
    apply from: 'fetch_napi_qjs_libs.gradle'
    apply from: 'fetch_napi_hermes_libs.gradle'
    apply from: 'build_jsc.gradle'
    apply from: 'build_quickjs.gradle'
    apply from: 'build_hermes.gradle'
    apply from: 'build_napi.gradle'
    // 由于每个字gradle中只会设置一个cmake路径，所以这里需要设置一个总的cmake路径
    android {
        externalNativeBuild {
            cmake {
                path "src/main/jni/CMakeLists.txt"
            }
        }
    }
} else if (project.COMPILE_JS_ENGINE == 'JSC') {
    apply from: 'fetch_jsc_libs.gradle'
    apply from: 'build_jsc.gradle'
} else if (project.COMPILE_JS_ENGINE == 'QuickJS') {
    apply from: 'fetch_napi_qjs_libs.gradle'
    apply from: 'build_quickjs.gradle'
} else if (project.COMPILE_JS_ENGINE == 'Hermes') {
    apply from: 'fetch_napi_hermes_libs.gradle'
    apply from: 'build_hermes.gradle'
} else if (project.COMPILE_JS_ENGINE == 'NAPI') {
    if (project.NAPI_ENGINE == 'QuickJS') {
        apply from: 'fetch_napi_qjs_libs.gradle'
    } else if (project.NAPI_ENGINE == 'Hermes') {
        apply from: 'fetch_napi_hermes_libs.gradle'
    }
    apply from: 'build_napi.gradle'
}

preBuild.dependsOn pickLibs
clean.dependsOn cleanPickLibs

android {

    ndkVersion "21.4.7075529"

    defaultConfig {

        ndk {
            abiFilters 'armeabi-v7a','x86','arm64-v8a','x86_64'
        }

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        // 使打包后的aar带有该混淆规则的文件
        consumerProguardFiles 'proguard-rules.pro'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.so'])

    api  rootProject.ext.androidx["annotation"]
    api 'com.google.code.gson:gson:2.8.5'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.0.2'


}