For example, I know that there is CoreCrypto
for kotlin native. How to modify kotlin gradle script so the following code compiles:
import kotlinx.cinterop.*
import platform.CoreCrypto.CC_SHA256 // compile error, obviously, as there's no depenedncy
import platform.CoreCrypto.CC_SHA256_DIGEST_LENGTH
fun main() {
// ...
}
My gradle script:
plugins {
kotlin("multiplatform") version "1.6.10"
}
group = "com.jaga"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
kotlin {
val 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"
}
}
}
sourceSets {
val nativeMain by getting
val nativeTest by getting
}
}
I've been searching for a solution literally for hours now.
Docs: https://kotlinlang.org/docs/native-platform-libs.html
There are examples here: https://github.com/JetBrains/kotlin/tree/master/kotlin-native/samples
But they are not self-contained and handle dependencies in some complicated generic way which I cannot reproduce in a single gradle script.
EDIT: Actually, even those samples fail to build so they aren't useful as a reference...