martmists
04/21/2022, 12:59 PMAnton Lakotka [JB]
04/21/2022, 2:24 PMmartmists
04/21/2022, 2:42 PMmartmists
04/21/2022, 2:43 PMAnton Lakotka [JB]
04/21/2022, 2:47 PMmartmists
04/21/2022, 2:49 PMAnton Lakotka [JB]
04/21/2022, 2:57 PMval nativeTarget = when {
hostOs == "Mac OS X" -> macosX64()
hostOs == "Linux" -> linuxX64()
isMingwX64 -> mingwX64()
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
it is just a trick used in samples to have the right target selected for users on different hosts.
It shouldn't be used in libraries that are meant to be published.
You need a proper layout with all targets you want to support.
Like this one:
kotlin {
macosX64() // what about arm64?
linuxX64() // what about arm64?
mingwX64()
sourceSets {
val commonMain by getting
val macosX64Main by getting
val linuxX64Main by getting
val mingwX64Main by getting
val nativeMain by creating {
this.dependsOn(commonMain)
macosX64Main.dependsOn(this)
linuxX64Main.dependsOn(this)
mingwX64Main.dependsOn(this)
}
}
}
Then upon publishing, you will publish libraries for all targets that can be used by consumers.
The only thing is that you have to be aware of host-specific targets such as macosX64. They have to be published separately.
So please read https://kotlinlang.org/docs/multiplatform-publish-lib.html
It should make it clearer for you.Anton Lakotka [JB]
04/21/2022, 2:59 PMpublishing {
repositories {
maven("/home/username/my-test-repo")
}
}
martmists
04/21/2022, 3:21 PMAnton Lakotka [JB]
04/21/2022, 3:23 PMmartmists
04/21/2022, 3:26 PM{
"schemaVersion": "1.0.0",
"buildSystem": "Gradle",
"buildSystemVersion": "7.4.2",
"buildPlugin": "org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper",
"buildPluginVersion": "1.6.20",
"projectSettings": {
"isHmppEnabled": true,
"isCompatibilityMetadataVariantEnabled": false
},
"projectTargets": [
{
"target": "org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests",
"platformType": "native",
"extras": {
"native": {
"konanTarget": "macos_x64",
"konanVersion": "1.6.20",
"konanAbiVersion": "1.6.0"
}
}
},
{
"target": "org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget",
"platformType": "common"
}
]
}
(this behavior also exists in the .module file)martmists
04/21/2022, 3:32 PM> Task :kpy-library:cinteropPythonMingwX64 FAILED
Exception in thread "main" java.lang.Error: /usr/include/python3.10/pyport.h:235:10: fatal error: 'sys/select.h' file not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:273)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1189)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1178)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1174)
at org.jetbrains.kotlin.native.interop.gen.jvm.DefaultPlugin.buildNativeIndex(Plugins.kt:33)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:272)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)