Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plans to support Kotlin Native? #40

Closed
dkotrada opened this issue Dec 21, 2018 · 13 comments
Closed

Any plans to support Kotlin Native? #40

dkotrada opened this issue Dec 21, 2018 · 13 comments

Comments

@dkotrada
Copy link

Would be great for CLI .

@ajalt
Copy link
Owner

ajalt commented Dec 21, 2018

That would be great to do at some point. I think most of the work would involve rewriting TermUi and Editor. We also access java class names in a few places, and have some option extensions that are jvm only, and so would need to be moved to a new file.

@ajalt
Copy link
Owner

ajalt commented May 12, 2019

I have a working prototype of a multi-platform project with native support for windows and linux targets in the multiplatform branch. There's no OSX target, because I don't have a Mac computer, and cross-compilation for OSX targets is not supported (apparently due to legal reasons, so I don't expect that support to be added.)

There are a few things holding me back from releasing it: There are some dokka bugs causing broken API doc output, and I haven't yet managed to set up publishing. I also haven't reimplemented the file editing functionality for the native targets, although I would be ok with simply documenting its absence, since I don't think it a commonly used feature.

If anyone is interested in trying it out, you should be able to checkout that branch, build the clikt klib from source and include it manually.

@dhakehurst
Copy link

I would love the mpp version

@dhakehurst
Copy link

I checked out the multiplatform branch,
seems to build fine if I add a macosX64 (OSX) target, and simply copy the linux code into it.

you also need a JS target to be multiplatform....even if the functions are filled with TODO()

@jmfayard
Copy link
Contributor

jmfayard commented Oct 3, 2019

@ajalt is that a good solution for the "I don't have a mac" problem? #93

@fuzzyweapon
Copy link

I can confirm. The way the kotlin multiplatform plugin works for native is to generally expect it to only compile a target if the machine is that target platform. I worked on cross-platform Gradle build work for a multi-platform product in my job and while we hadn't gotten to Native support, I was recon-ing it (so this knowledge comes out of my recon from a few months ago, though things are moving fast).

Since mac is a POSIX system, all you need to do is make sure that the code for linux is POSIX compatible and it should work nearly everywhere.

If you have the need to actually release mac target packages (in general), you just need a contributor who owns a mac to trigger your publishing pipeline for that target. Pretty easy once it is all setup.

@jmfayard
Copy link
Contributor

@ajalt
Paul Merlin from Gradle has a ready to use Gradle Action
https://github.com/marketplace/actions/gradle-command

Maybe that's all what you need to build on a system that you don't have

@ajalt
Copy link
Owner

ajalt commented Feb 13, 2020

@dkotrada @dhakehurst @jmfayard @fuzzyweapon

I just released a beta of the next version of Clikt, which has full multiplatform support. This version implements all functionality for JVM, NodeJS, and native Windows, Linux, and MacOS.

For all non-JVM MPP targets, you can use this dependency:

api("com.github.ajalt:clikt-multiplatform:2.5.0-beta1")

It would be very helpful if anyone is able to try it out and let me know if it works for you. You can comment here or DM me on the ASG or kotlinlang slack.

Thank you!

@yousuf-haque
Copy link

@ajalt I tried the kmpp dependency for clikt.

I was able to sync gradle with that dependencies and build the binary but the library doesn't seem to be on the IDE's classpath and I don't get autocompletion when editing a .kt file with the Clikt library. Additionally, if I type out the import statements and the Clikt classes manually and try to compile, I still get a compilation error - I don't think the issue is with the ide's classpath specifically.

Any ideas?
What would be easiest is if you could point me to a kotlin native sample app that consumes this library.

Thanks!
This is my gradle file:

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
}
repositories {
    mavenCentral()
}
kotlin {
    // For ARM, should be changed to iosArm32 or iosArm64
    // For Linux, should be changed to e.g. linuxX64
    // For MacOS, should be changed to e.g. macosX64
    // For Windows, should be changed to e.g. mingwX64
    macosX64("macos") {
        binaries {
            executable {
                // Change to specify fully qualified name of your application's entry point:
               entryPoint = 'sample.main'
                // Specify command-line arguments, if necessary:
                runTask?.args('-o', 'foobar')
            }
        }
        compilations["main"].enableEndorsedLibs = true

    }
    sourceSets {
        // Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
        // in gradle.properties file and re-import your project in IDE.
        macosMain {
            dependencies {
                implementation("com.github.ajalt:clikt-multiplatform:2.5.0-beta1")
            }
        }
        macosTest {
            dependencies {
                implementation("com.github.ajalt:clikt-multiplatform:2.5.0-beta1")
            }
        }
    }

}


// Use the following Gradle tasks to run your application:
// :runReleaseExecutableMacos - without debug symbols
// :runDebugExecutableMacos - with debug symbols

@ajalt
Copy link
Owner

ajalt commented Feb 18, 2020

@yousuf-haque thank you for trying out the beta!

Your gradle configuration looks fine; I'm able to get completion and builds working with that configuration on both Gradle 5.4 and 6.1.

Here's an example project with a similar configuration to yours, which works in both IntelliJ and gradle:
clikt-native-sample.zip

@audkar
Copy link

audkar commented Feb 18, 2020

I am also using clikt native (linux). It work perfectly! Only difference I can see, is that I am using api instead of implementation while declaring dependency

@yousuf-haque
Copy link

I updated to gradle 6.1.1( from 5.5.1) and that seemed to do the trick.

Thanks!

@ajalt
Copy link
Owner

ajalt commented Feb 23, 2020

Clikt 2.5.0 has been released. Thank you to everyone who provided feedback!

@ajalt ajalt closed this as completed Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants