From 5ca85336c6d645235614e19665068076e3861842 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Sat, 22 Oct 2022 21:04:37 +0400 Subject: [PATCH] Support two more Apple targets --- .../kscience/gradle/KScienceExtension.kt | 22 ++++++++++++++++--- .../kscience/gradle/KScienceProjectPlugin.kt | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt index 2c6051d..d66b0dc 100644 --- a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt +++ b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt @@ -212,8 +212,10 @@ public enum class KotlinNativePreset { linuxX64, mingwX64, macosX64, + macosArm64, iosX64, - iosArm64 + iosArm64, + iosSimulatorArm64, } public data class KScienceNativeTarget( @@ -225,8 +227,10 @@ public data class KScienceNativeTarget( public val linuxX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.linuxX64) public val mingwX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.mingwX64) public val macosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosX64) + public val macosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosX64) public val iosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosX64) public val iosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosArm64) + public val iosSimulatorArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosSimulatorArm64) } } @@ -235,15 +239,17 @@ public class KScienceNativeConfiguration { KScienceNativeTarget.linuxX64, KScienceNativeTarget.mingwX64, KScienceNativeTarget.macosX64, + KScienceNativeTarget.macosArm64, KScienceNativeTarget.iosX64, KScienceNativeTarget.iosArm64, - ).associateBy { it.preset }.toMutableMap() + KScienceNativeTarget.iosSimulatorArm64, + ).associateByTo(mutableMapOf()) { it.preset } /** * Replace all targets */ public fun setTargets(vararg target: KScienceNativeTarget) { - targets = target.associateBy { it.preset }.toMutableMap() + targets = target.associateByTo(mutableMapOf()) { it.preset } } /** @@ -325,6 +331,11 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro nativeTarget.targetConfiguration ) + KotlinNativePreset.macosArm64 -> macosX64( + nativeTarget.targetName, + nativeTarget.targetConfiguration + ) + KotlinNativePreset.iosX64 -> iosX64( nativeTarget.targetName, nativeTarget.targetConfiguration @@ -335,6 +346,11 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro nativeTarget.targetConfiguration ) + KotlinNativePreset.iosSimulatorArm64 -> iosArm64( + nativeTarget.targetName, + nativeTarget.targetConfiguration + ) + // else -> { // logger.error("Native preset ${nativeTarget.preset} not recognised.") // null diff --git a/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt index 676c9f5..2f0a3e1 100644 --- a/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt @@ -254,7 +254,7 @@ public open class KScienceProjectPlugin : Plugin { val pattern = "publish(?.*)PublicationTo${repositoryNameCapitalized}Repository" .toRegex() - tasks.withType().toList().forEach forEachPublication@{ + tasks.withType().forEach forEachPublication@{ val matchResult = pattern.matchEntire(it.name) ?: return@forEachPublication val publicationName = matchResult.groups["publication"]!!.value.capitalize() val releaseTaskName = "release$publicationName"