Wietlol
02/25/2022, 11:02 PMval hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
which works and generates a windows ".exe" file
I can also change the first line to a literal "Linux"
(to pretend I am on a linux) and it works and generates a linux ".kexe" file
but I can't figure out how to make it generate both a linux ánd a windows executableephemient
02/25/2022, 11:07 PMmacosX64 {
binaries {
executable {
entryPoint = "main"
}
}
}
linuxX64 {
binaries {
executable {
entryPoint = "main"
}
}
}
mingwX64 {
binaries {
executable {
entryPoint = "main"
}
}
}
(you can of course abstract out the common target configuration block as well)ephemient
02/25/2022, 11:08 PMWietlol
02/25/2022, 11:09 PMephemient
02/25/2022, 11:10 PMWietlol
02/25/2022, 11:10 PMephemient
02/25/2022, 11:11 PMWietlol
02/25/2022, 11:12 PMephemient
02/25/2022, 11:15 PMkotlin {
sourceSets{
val commonMain by getting
val nativeMain by creating {
dependsOn(commonMain)
}
val macosX64Main by getting {
dependsOn(nativeMain)
}
val linuxX64Main by getting {
dependsOn(nativeMain)
}
val mingwX64Main by getting {
dependsOn(nativeMain)
}
}
}
Wietlol
02/25/2022, 11:16 PMsourceSets {
val nativeMain by getting
val nativeTest by getting
}
changing that to
sourceSets {
val commonMain by getting
val commonTest by getting
}
fixed itWietlol
02/25/2022, 11:16 PMephemient
02/25/2022, 11:16 PMephemient
02/25/2022, 11:17 PMWietlol
02/25/2022, 11:18 PMWietlol
02/25/2022, 11:18 PMWietlol
02/25/2022, 11:18 PM