plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.engineer1109.learnvulkan"
        minSdkVersion 25
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-Ofast"
            }
        }

        ndk {
            abiFilters 'arm64-v8a', 'x86_64'
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dataBinding {
        enabled = true
    }

    viewBinding {
        enabled = true
    }

    sourceSets {
        main.assets.srcDirs = ['assets']
        main.jniLibs.srcDirs = ['lib']
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

task copyTask {
    copy {
        from '../../data/textures'
        into "assets/textures"
    }
    copy {
        from '../../data/shaders/StaticTriangle'
        into "assets/shaders/StaticTriangle"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/shaders/StaticCube'
        into "assets/shaders/StaticCube"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/shaders/Texture2dCube'
        into "assets/shaders/Texture2dCube"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/shaders/Skybox'
        into "assets/shaders/Skybox"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/shaders/PhongLighting'
        into "assets/shaders/PhongLighting"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/shaders/InstanceDraw'
        into "assets/shaders/InstanceDraw"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/shaders/ShadowMapping'
        into "assets/shaders/ShadowMapping"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/shaders/ShadowMappingOnmi'
        into "assets/shaders/ShadowMappingOnmi"
        include '**/*.so.vert'
        include '**/*.so.frag'
    }
    copy {
        from '../../data/models'
        into "assets/models"
        include '**/*.*'
        include '**/*.*'
    }
    copy {
        from '../../third_party/assimp/lib/android'
        into "lib"
        include '**/*.so'
        include '**/*.so'
    }
}

preBuild.dependsOn copyTask