[K/N] Samples: Migrate 'echoServer' to modern multiplatform
^KT-50547 Fixed
This commit is contained in:
committed by
Space Team
parent
97ef2de6e3
commit
359f5fe7b3
@@ -49,7 +49,7 @@ val buildSamplesWithPlatformLibs by tasks.creating {
|
|||||||
dependsOn(":workers:assemble")
|
dependsOn(":workers:assemble")
|
||||||
|
|
||||||
if (isMacos || isLinux) {
|
if (isMacos || isLinux) {
|
||||||
dependsOn(":echoServer:assemble") // https://youtrack.jetbrains.com/issue/KT-50547
|
dependsOn(":echoServer:assemble") //https://youtrack.jetbrains.com/issue/KT-63721/
|
||||||
dependsOn(":nonBlockingEchoServer:assemble")
|
dependsOn(":nonBlockingEchoServer:assemble")
|
||||||
dependsOn(":tensorflow:assemble")
|
dependsOn(":tensorflow:assemble")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,22 @@
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
val additionalPresets: List<KotlinNativeTargetPreset> = listOf("linuxArm64").map {
|
|
||||||
kotlin.presets[it] as KotlinNativeTargetPreset
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
// Determine host preset.
|
macosX64()
|
||||||
val hostOs = System.getProperty("os.name")
|
macosArm64()
|
||||||
|
linuxArm64()
|
||||||
|
linuxX64()
|
||||||
|
/*
|
||||||
|
https://youtrack.jetbrains.com/issue/KT-63721/Commonizer-Uncovered-platform.posix.socket-not-commonized-for-mingw-linux-macos
|
||||||
|
Not building for windows, because it would require writing expect/actuals around
|
||||||
|
signed vs unsigned socket APIs:
|
||||||
|
mingwX64()
|
||||||
|
*/
|
||||||
|
|
||||||
// Create a target for the host platform.
|
targets.withType<KotlinNativeTarget>().configureEach {
|
||||||
val hostTarget = when {
|
|
||||||
hostOs == "Mac OS X" -> macosX64("echoServer")
|
|
||||||
hostOs == "Linux" -> linuxX64("echoServer")
|
|
||||||
hostOs.startsWith("Windows") -> mingwX64("echoServer")
|
|
||||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create cross-targets.
|
|
||||||
val additionalTargets = additionalPresets.map { preset ->
|
|
||||||
val targetName = "echoServer${preset.name.capitalize()}"
|
|
||||||
targetFromPreset(preset, targetName) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure executables for all targets.
|
|
||||||
configure(additionalTargets + listOf(hostTarget)) {
|
|
||||||
binaries {
|
binaries {
|
||||||
executable {
|
executable {
|
||||||
entryPoint = "sample.echoserver.main"
|
entryPoint = "sample.echoserver.main"
|
||||||
@@ -35,17 +24,4 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
val echoServerMain by getting
|
|
||||||
additionalPresets.forEach { preset ->
|
|
||||||
val mainSourceSetName = "echoServer${preset.name.capitalize()}Main"
|
|
||||||
getByName(mainSourceSetName).dependsOn(echoServerMain)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable experimental stdlib API used by the sample.
|
|
||||||
sourceSets.all {
|
|
||||||
languageSettings.optIn("kotlin.ExperimentalStdlibApi")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.import.noCommonSourceSets=true
|
|
||||||
|
|||||||
Reference in New Issue
Block a user