/**
 * This file was created using the `create_project.py` script located in the
 * `<AndroidX root>/development/project-creator` directory.
 *
 * Please use that script when creating a new project, rather than copying an existing project and
 * modifying its settings.
 */
import androidx.build.PlatformIdentifier
import androidx.build.LibraryType
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFrameworkConfig

plugins {
    id("AndroidXPlugin")
}

androidXMultiplatform {
    def xcf = new XCFrameworkConfig(project, "AndroidXDarwinBenchmarks")
    ios {
        binaries.framework {
            baseName = "AndroidXDarwinBenchmarks"
            // https://youtrack.jetbrains.com/issue/KT-48552
            embedBitcode = BitcodeEmbeddingMode.DISABLE
            xcf.add(it)
        }
    }
    // needed for snapshot publishing to trigger component creation
    jvm()
    // default platform is not JVM but we need to use it because it is
    // the only platform built on all machines
    defaultPlatform(PlatformIdentifier.JVM)
    sourceSets {
        darwinMain {
            dependsOn(commonMain)
            dependencies {
                api(libs.kotlinStdlib)
            }
        }
        darwinTest {
            dependsOn(commonTest)
            dependencies {
                implementation(libs.kotlinTest)
                implementation(libs.kotlinTestAnnotationsCommon)
            }
        }
        iosMain {
            dependsOn(darwinMain)
            dependencies {
                api(project(":benchmark:benchmark-darwin-core"))
            }
        }
        iosArm64Main {
            dependsOn(iosMain)
        }
        iosSimulatorArm64Main {
            dependsOn(iosMain)
        }
        iosX64Main {
            dependsOn(iosMain)
        }
        targets.configureEach { target ->
            if (target.platformType == KotlinPlatformType.native) {
                target.compilations["main"].defaultSourceSet {
                    dependsOn(darwinMain)
                }
                target.compilations["test"].defaultSourceSet {
                    dependsOn(darwinTest)
                }
                target.compilations.configureEach {
                    compilerOptions.options.optIn.add("kotlinx.cinterop.ExperimentalForeignApi")
                }
            }
        }
    }
    kotlin.metadata {
        // KT-63338
        compilations.matching { it.name == "iosMain" }.configureEach {
            it.compileTaskProvider.configure {
                enabled = false
            }
        }
    }
}

androidx {
    name = "Benchmarks - Darwin"
    inceptionYear = "2022"
    description = "AndroidX Benchmarks - Darwin"
    type = LibraryType.SNAPSHOT_ONLY_LIBRARY
}
