buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        // The Android Gradle Plugin knows how to build native code with the NDK.
        classpath("com.android.tools.build:gradle:8.7.0")
    }
}

plugins {
    id 'com.android.library'
    id 'org.mozilla.rust-android-gradle.rust-android' version '0.9.6'
    id 'org.equalitie.ouisync.convention'
}

group = "org.equalitie.logtee"
version = "1.0"


rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

android {
    namespace = "org.equalitie.logtee"

    compileSdk = 35

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }

    defaultConfig {
        minSdk = 21

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

cargo {
    module = '../../..'
    libname = 'logtee'
    profile = 'release'
    targets = ['arm', 'arm64', 'x86_64']
    extraCargoBuildArguments = ['--package', 'logtee']
}

afterEvaluate {
    android.libraryVariants.each {
        def variant = it.name.capitalize()

        // Build the native library for the target android platforms.
        tasks.named("merge${variant}JniLibFolders") {
            dependsOn 'cargoBuild'
        }
    }
}
