/**
 * 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 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")
    id("androidx.benchmark.darwin")
}

androidXMultiplatform {
    // XCFrameworkConfig must always be called AndroidXDarwinBenchmarks
    def xcf = new XCFrameworkConfig(project, "AndroidXDarwinBenchmarks")
    jvm() // add an empty compilation to prevent the warning for unused sourceSets.
    ios {
        binaries.framework {
            // The module name must be AndroidXDarwinBenchmarks for the discovery to work.
            baseName = "AndroidXDarwinBenchmarks"
            // https://youtrack.jetbrains.com/issue/KT-48552
            embedBitcode = BitcodeEmbeddingMode.DISABLE
            export(project(":benchmark:benchmark-darwin"))
            xcf.add(it)
        }
    }

    sourceSets {
        iosMain {
            dependsOn(commonMain)
            dependencies {
                api(libs.kotlinStdlib)
                api(project(":benchmark:benchmark-darwin"))
            }
        }
        iosArm64Main {
            dependsOn(iosMain)
        }
        iosSimulatorArm64Main {
            dependsOn(iosMain)
        }
        iosX64Main {
            dependsOn(iosMain)
        }
    }

    targets.configureEach { target ->
        if (target.platformType == KotlinPlatformType.native) {
            target.compilations.configureEach {
                compilerOptions.options.optIn.add("kotlinx.cinterop.ExperimentalForeignApi")
            }
        }
    }
}

darwinBenchmark {
    xcodeGenConfigFile = project.rootProject.file(
            "benchmark/benchmark-darwin-xcode/projects/benchmark-darwin-samples-xcode.yml"
    )
    xcodeProjectName = "benchmark-darwin-samples-xcode"
    scheme = "testapp-ios"
    // To run locally switch to iOS 17.0 simulators
    destination = "platform=iOS Simulator,name=iPhone 13,OS=15.2"
    referenceSha.set(androidx.getReferenceSha())
}

androidx {
    name = "Benchmarks - Darwin Samples"
    inceptionYear = "2022"
    description = "AndroidX Benchmarks - Darwin Samples"
}
