I build my first KN as below, gradle init
, then updating the build.gradle
with the code below, then running gradle build
, using my Mac:
build.gradle
:
buildscript {
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
}
}
apply plugin: 'konan'
// Compile this component for 64-bit MacOS, Linux and Windows.
konan.targets = [
'wasm32',
'android_arm32', 'android_arm64',
// 'mingw_x64',
// 'linux_x64', 'linux_arm32_hfp',
'macos_x64',
// 'ios_x64', 'ios_arm32', 'ios_arm64'
]
konanArtifacts {
library('utils') {
srcFiles fileTree('src/libs/utils')
}
program('hello') {
libraries {
artifact 'utils'
}
}
}
My app structure is:
hello.kt
(app):
fun main() {
println("Hello Gradle!")
}
foo.kt
(lib):
fun foo(){
println("Hello Gradle! again")
}
by running gradle build
: I got the libs and executables as in the below tree:
I’ve the below questions:
-
Nothing had been generated for the following targets, this is why I made them as comments:
iOS: ios_x64, ios_arm32, ios_arm64
Raspberry: linux_arm32_hfp
Windows: mingw_x64
Linux: linux_x64 -
Are all the generated libraries
utils.Klib
are same, so I can pick anyone of them and use it anywhere, or I’ve to pick as per the required target. -
How to call the function
foo
that is part of the library in themain
function, I triedimport utils
then callingutils.foo()
but did not work.