plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.kotlin.compose)
}

val sdkHome = System.getenv("ANDROID_HOME") as String
val ndkHome = System.getenv("ANDROID_NDK_HOME") as String
val vcpkgHome = System.getenv("VCPKG_ROOT") as String

android {
    namespace = "com.omixlab.mosis"

    compileSdk {
        version = release(36)
    }
    ndkVersion = "29.0.14206865"

    defaultConfig {
        applicationId = "com.omixlab.mosis"
        minSdk = 34
        targetSdk = 36
        versionCode = 1
        versionName = "1.0"
        ndk {
            abiFilters += listOf("arm64-v8a")
        }
        externalNativeBuild {
            cmake {
                //arguments += "--trace-expand"
                cppFlags += ""
                arguments += "-DANDROID_STL=c++_shared"
                arguments += "-DCMAKE_TOOLCHAIN_FILE=$vcpkgHome/scripts/buildsystems/vcpkg.cmake"
                arguments += "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ndkHome/build/cmake/android.toolchain.cmake"
                arguments += "-DVCPKG_TARGET_TRIPLET=arm64-android"
                arguments += "-DANDROID_SDK=$sdkHome"
                arguments += "-DANDROID_NDK=$ndkHome"
                targets += "mosis-service"
                targets += "mosis-test"
            }
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlin {
        compilerOptions {
            jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
        }
    }
    buildFeatures {
        viewBinding = true
        aidl = true
    }
    externalNativeBuild {
        cmake {
            path = file("src/main/cpp/CMakeLists.txt")
            version = "4.1.2"
        }
    }
}

dependencies {
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.androidx.activity.compose)
    implementation(libs.androidx.compose.ui)
    implementation(libs.androidx.compose.material3)
    implementation(libs.material)
    implementation(libs.androidx.constraintlayout)
    implementation(libs.androidx.activity)
    implementation(libs.androidx.compose.foundation)
    implementation(libs.androidx.material3)
}