Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ repositories {
}

dependencies {
compileOnly(kotlin("gradle-plugin"))
compileOnly(kotlin("gradle-plugin", "1.5.30"))
testImplementation("io.kotest:kotest-runner-junit5:4.3.0")
testImplementation("io.kotest:kotest-assertions-core:4.3.0")
testImplementation("io.kotest:kotest-property:4.3.0")
testImplementation("io.mockk:mockk:1.10.0")
testImplementation(kotlin("gradle-plugin"))
testImplementation(kotlin("gradle-plugin", "1.5.30"))
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package com.chromaticnoise.multiplatformswiftpackage.domain
internal enum class TargetName(val identifier: String) {
IOSarm64("iosArm64"),
IOSx64("iosX64"),
IOSSimulatorArm64("iosSimulatorArm64"),
WatchOSarm32("watchosArm32"),
WatchOSarm64("watchosArm64"),
WatchOSx86("watchosX86"),
WatchOSx64("watchosX64"),
WatchOSSimulatorArm64("watchosSimulatorArm64"),
TvOSarm64("tvosArm64"),
TvOSx64("tvosX64"),
MacOSx64("macosX64");
TvOSSimulatorArm64("tvosSimulatorArm64"),
MacOSx64("macosX64"),
MacOSArm64("macosArm64");

internal companion object {
private val map = values().associateBy(TargetName::identifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ internal val Collection<Either<List<PluginConfiguration.PluginConfigurationError
internal val TargetName.konanTarget: KonanTarget get() = when (this) {
TargetName.IOSarm64 -> KonanTarget.IOS_ARM64
TargetName.IOSx64 -> KonanTarget.IOS_X64
TargetName.IOSSimulatorArm64 -> KonanTarget.IOS_SIMULATOR_ARM64
TargetName.WatchOSarm32 -> KonanTarget.WATCHOS_ARM32
TargetName.WatchOSarm64 -> KonanTarget.WATCHOS_ARM64
TargetName.WatchOSx86 -> KonanTarget.WATCHOS_X86
TargetName.WatchOSx64 -> KonanTarget.WATCHOS_X64
TargetName.WatchOSSimulatorArm64 -> KonanTarget.WATCHOS_SIMULATOR_ARM64
TargetName.TvOSarm64 -> KonanTarget.TVOS_ARM64
TargetName.TvOSx64 -> KonanTarget.TVOS_X64
TargetName.TvOSSimulatorArm64 -> KonanTarget.TVOS_SIMULATOR_ARM64
TargetName.MacOSx64 -> KonanTarget.MACOS_X64
TargetName.MacOSArm64 -> KonanTarget.MACOS_ARM64
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import groovy.lang.Closure
import org.gradle.util.ConfigureUtil

/**
* DSL to create instances of [TargetPlatform].
*/
* DSL to create instances of [TargetPlatform].
*/
public class TargetPlatformDsl {
internal var targetPlatforms = mutableListOf<Either<List<PluginConfigurationError>, TargetPlatform>>()

Expand All @@ -21,7 +21,14 @@ public class TargetPlatformDsl {
* @param version builder for an instance of [PlatformVersion]
*/
public fun iOS(version: PlatformVersionDsl.() -> Unit) {
targetsInternal(listOf(Either.Right(TargetName.IOSarm64), Either.Right(TargetName.IOSx64)), version)
targetsInternal(
listOf(
Either.Right(TargetName.IOSarm64),
Either.Right(TargetName.IOSx64),
Either.Right(TargetName.IOSSimulatorArm64)
),
version
)
}

public fun iOS(version: Closure<PlatformVersionDsl>) {
Expand All @@ -34,11 +41,14 @@ public class TargetPlatformDsl {
* @param version builder for an instance of [PlatformVersion]
*/
public fun watchOS(version: PlatformVersionDsl.() -> Unit) {
targetsInternal(listOf(
Either.Right(TargetName.WatchOSarm32),
Either.Right(TargetName.WatchOSarm64),
Either.Right(TargetName.WatchOSx86),
Either.Right(TargetName.WatchOSx64)),
targetsInternal(
listOf(
Either.Right(TargetName.WatchOSarm32),
Either.Right(TargetName.WatchOSarm64),
Either.Right(TargetName.WatchOSx86),
Either.Right(TargetName.WatchOSx64),
Either.Right(TargetName.WatchOSSimulatorArm64)
),
version
)
}
Expand All @@ -53,7 +63,14 @@ public class TargetPlatformDsl {
* @param version builder for an instance of [PlatformVersion]
*/
public fun tvOS(version: PlatformVersionDsl.() -> Unit) {
targetsInternal(listOf(Either.Right(TargetName.TvOSarm64), Either.Right(TargetName.TvOSx64)), version)
targetsInternal(
listOf(
Either.Right(TargetName.TvOSarm64),
Either.Right(TargetName.TvOSx64),
Either.Right(TargetName.TvOSSimulatorArm64)
),
version
)
}

public fun tvOS(version: Closure<PlatformVersionDsl>) {
Expand All @@ -66,7 +83,13 @@ public class TargetPlatformDsl {
* @param version builder for an instance of [PlatformVersion]
*/
public fun macOS(version: PlatformVersionDsl.() -> Unit) {
targetsInternal(listOf(Either.Right(TargetName.MacOSx64)), version)
targetsInternal(
listOf(
Either.Right(TargetName.MacOSx64),
Either.Right(TargetName.MacOSArm64)
),
version
)
}

public fun macOS(version: Closure<PlatformVersionDsl>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class TargetPlatformDslTest : StringSpec() {
.shouldHaveTarget("iosX64")
}

"adding ios targets should add arm 64 simulator target" {
TargetPlatformDsl().apply { iOS(someVersion) }.targetPlatforms
.shouldHaveTarget("iosSimulatorArm64")
}

"adding watchOS targets should add arm 32 target" {
TargetPlatformDsl().apply { watchOS(someVersion) }.targetPlatforms
.shouldHaveTarget("watchosArm32")
Expand All @@ -40,6 +45,11 @@ class TargetPlatformDslTest : StringSpec() {
.shouldHaveTarget("watchosX86")
}

"adding watchOS targets should add arm 64 simulator target" {
TargetPlatformDsl().apply { watchOS(someVersion) }.targetPlatforms
.shouldHaveTarget("watchosSimulatorArm64")
}

"adding tvOS targets should add arm 64 target" {
TargetPlatformDsl().apply { tvOS(someVersion) }.targetPlatforms
.shouldHaveTarget("tvosArm64")
Expand All @@ -50,11 +60,21 @@ class TargetPlatformDslTest : StringSpec() {
.shouldHaveTarget("tvosX64")
}

"adding tvOS targets should add arm 64 simulator target" {
TargetPlatformDsl().apply { tvOS(someVersion) }.targetPlatforms
.shouldHaveTarget("tvosSimulatorArm64")
}

"adding macOS targets should add x64 target" {
TargetPlatformDsl().apply { macOS(someVersion) }.targetPlatforms
.shouldHaveTarget("macosX64")
}

"adding macOS targets should add arm 64 target" {
TargetPlatformDsl().apply { macOS(someVersion) }.targetPlatforms
.shouldHaveTarget("macosArm64")
}

"adding target without names should not add a platform target" {
TargetPlatformDsl().apply { targets(version = someVersion) }.targetPlatforms
.shouldBeEmpty()
Expand Down