https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
a

Adam S

01/21/2023, 8:44 PM
I’ve got an example directory with multiple Kotlin/Native files, each with a
fun main() {}
. Is there an easy way with Gradle to create executables for each file? So one Kotlin/Native Gradle project can produce multiple executables? I’ve tried creating a separate target for each file, but it’s really messy - with conflicting Configurations and overlapping sources…
e

ephemient

01/21/2023, 9:12 PM
it's much easier than that
Copy code
kotlin {
    linuxX64 {
        binaries {
            executable("one") {
                entryPoint("pkg.one.main")
            }
            executable("two") {
                entryPoint("pkg.two.main")
            }
            executable("...") {
Copy code
./gradlew link{One,Two,...}{Debug,Release}ExecutableLinuxX64
ls build/bin/linuxX64/{one,two,...}{Debug,Release}Executable/{one,two,...}.kexe
can be applied to native targets other than
linuxX64
too, of course
a

Adam S

01/22/2023, 12:55 PM
thanks! Here’s how I’ve done it dynamically
2 Views