Skip to content

Commit

Permalink
apple simulator targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetuska committed Oct 13, 2021
1 parent b038937 commit 82cc8bb
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 85 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* Introduced nativeMain and nativeTest sourceSets
* Added BlockingTest utility interface
* Removed snapshot repository support
* macosArm64() target added
* iosSimulatorArm64() target added
* watchosSimulatorArm64() target added
* tvosSimulatorArm64() target added

# v1.1.1

Expand Down
29 changes: 18 additions & 11 deletions buildSrc/src/main/kotlin/plugin.library-mpp.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kotlin {
dependsOn(commonTest)
}
}

explicitApi()
jvm()
js {
Expand All @@ -48,13 +48,13 @@ kotlin {
// }
// }
}

nativeTargetGroup(
"androidNdk",
androidNativeArm32(),
androidNativeArm64(),
)

nativeTargetGroup(
"linux",
linuxX64(),
Expand All @@ -63,40 +63,47 @@ kotlin {
linuxArm64(),
linuxArm32Hfp(),
)

nativeTargetGroup(
"ios",
iosArm32(),
iosArm64(),
iosX64(),
iosSimulatorArm64(),
)

nativeTargetGroup(
"watchos",
watchosArm32(),
watchosArm64(),
watchosX86(),
watchosX64(),
watchosSimulatorArm64(),
)

nativeTargetGroup(
"tvos",
tvosArm64(),
tvosX64(),
tvosSimulatorArm64(),
)

macosX64()


nativeTargetGroup(
"macos",
macosX64(),
macosArm64(),
)

nativeTargetGroup(
"mingw",
mingwX86(),
mingwX64(),
)

val targetsWithCoroutines = KotlinTargetDetails.values()
.filter(KotlinTargetDetails::hasCoroutines)
.map(KotlinTargetDetails::presetName)

targets.filter { it.preset?.name in targetsWithCoroutines }
.forEach {
it.compilations["main"].defaultSourceSet {
Expand Down
151 changes: 77 additions & 74 deletions buildSrc/src/main/kotlin/util/KotlinTargetDetails.kt
Original file line number Diff line number Diff line change
@@ -1,74 +1,77 @@
package util

import org.jetbrains.kotlin.konan.target.Family
import org.jetbrains.kotlin.konan.target.KonanTarget


enum class KotlinTargetDetails(
val presetName: String,
val hasCoroutines: Boolean,
) {
JVM("jvm", true),
ANDROID("android", false),
JS("jsIr", true),

ANDROID_NDK_ARM32("androidNativeArm32", false),
ANDROID_NDK_ARM64("androidNativeArm64", false),

IOS_ARM32("iosArm32", true),
IOS_ARM64("iosArm64", true),
IOS_X64("iosX64", true),

WATCHOS_X86("watchosX86", true),
WATCHOS_X64("watchosX64", true),
WATCHOS_ARM64("watchosArm64", true),
WATCHOS_ARM32("watchosArm32", true),

TVOS_ARM64("tvosArm64", true),
TVOS_X64("tvosX64", true),

MACOS_X64("macosX64", true),

LINUX_ARM32_HFP("linuxArm32Hfp", false),
LINUX_MIPS32("linuxMips32", false),
LINUX_MIPSEL32("linuxMipsel32", false),
LINUX_X64("linuxX64", true),
LINUX_ARM64("linuxArm64", false),

MINGW_X64("mingwX64", true),
MINGW_X32("mingwX86", false),
}

val KonanTarget.buildHost: Family
get() = when (this) {
KonanTarget.ANDROID_X64,
KonanTarget.ANDROID_X86,
KonanTarget.ANDROID_ARM32,
KonanTarget.ANDROID_ARM64,
KonanTarget.LINUX_ARM64,
KonanTarget.LINUX_ARM32_HFP,
KonanTarget.LINUX_MIPS32,
KonanTarget.LINUX_MIPSEL32,
KonanTarget.LINUX_X64 -> Family.LINUX

KonanTarget.MINGW_X86,
KonanTarget.MINGW_X64 -> Family.MINGW

KonanTarget.IOS_ARM32,
KonanTarget.IOS_ARM64,
KonanTarget.IOS_X64,
KonanTarget.IOS_SIMULATOR_ARM64,
KonanTarget.WATCHOS_ARM32,
KonanTarget.WATCHOS_ARM64,
KonanTarget.WATCHOS_X86,
KonanTarget.WATCHOS_X64,
KonanTarget.WATCHOS_SIMULATOR_ARM64,
KonanTarget.TVOS_ARM64,
KonanTarget.TVOS_X64,
KonanTarget.TVOS_SIMULATOR_ARM64,
KonanTarget.MACOS_X64,
KonanTarget.MACOS_ARM64 -> Family.OSX

KonanTarget.WASM32 -> throw IllegalStateException("Target $this not supported")
is KonanTarget.ZEPHYR -> throw IllegalStateException("Target $this not supported")
}
package util

import org.jetbrains.kotlin.konan.target.Family
import org.jetbrains.kotlin.konan.target.KonanTarget

enum class KotlinTargetDetails(
val presetName: String,
val hasCoroutines: Boolean,
) {
JVM("jvm", true),
ANDROID("android", false),
JS("jsIr", true),

ANDROID_NDK_ARM32("androidNativeArm32", false),
ANDROID_NDK_ARM64("androidNativeArm64", false),

IOS_ARM32("iosArm32", true),
IOS_ARM64("iosArm64", true),
IOS_X64("iosX64", true),
IOS_SIMULATOR_ARM64("iosSimulatorArm64", true),

WATCHOS_X86("watchosX86", true),
WATCHOS_X64("watchosX64", true),
WATCHOS_ARM64("watchosArm64", true),
WATCHOS_ARM32("watchosArm32", true),
WATCHOS_SIMULATOR_ARM64("watchosSimulatorArm64", true),

TVOS_ARM64("tvosArm64", true),
TVOS_X64("tvosX64", true),
TVOS_SIMULATOR_ARM64("tvosSimulatorArm64", true),

MACOS_X64("macosX64", true),
MACOS_ARM64("macosArm64", true),

LINUX_ARM32_HFP("linuxArm32Hfp", false),
LINUX_MIPS32("linuxMips32", false),
LINUX_MIPSEL32("linuxMipsel32", false),
LINUX_X64("linuxX64", true),
LINUX_ARM64("linuxArm64", false),

MINGW_X64("mingwX64", true),
MINGW_X32("mingwX86", false),
}

val KonanTarget.buildHost: Family
get() = when (this) {
KonanTarget.ANDROID_X64,
KonanTarget.ANDROID_X86,
KonanTarget.ANDROID_ARM32,
KonanTarget.ANDROID_ARM64,
KonanTarget.LINUX_ARM64,
KonanTarget.LINUX_ARM32_HFP,
KonanTarget.LINUX_MIPS32,
KonanTarget.LINUX_MIPSEL32,
KonanTarget.LINUX_X64 -> Family.LINUX

KonanTarget.MINGW_X86,
KonanTarget.MINGW_X64 -> Family.MINGW

KonanTarget.IOS_ARM32,
KonanTarget.IOS_ARM64,
KonanTarget.IOS_X64,
KonanTarget.IOS_SIMULATOR_ARM64,
KonanTarget.WATCHOS_ARM32,
KonanTarget.WATCHOS_ARM64,
KonanTarget.WATCHOS_X86,
KonanTarget.WATCHOS_X64,
KonanTarget.WATCHOS_SIMULATOR_ARM64,
KonanTarget.TVOS_ARM64,
KonanTarget.TVOS_X64,
KonanTarget.TVOS_SIMULATOR_ARM64,
KonanTarget.MACOS_X64,
KonanTarget.MACOS_ARM64 -> Family.OSX

KonanTarget.WASM32 -> throw IllegalStateException("Target $this not supported")
is KonanTarget.ZEPHYR -> throw IllegalStateException("Target $this not supported")
}

0 comments on commit 82cc8bb

Please sign in to comment.