https://kotlinlang.org logo
Title
r

Rohde Fischer

05/17/2023, 6:16 AM
when running native/multiplatform it seems that my test tasks are not reached, I just get a:
> Task :rfpath-okio:nativeTest SKIPPED
Skipping task ':rfpath-okio:nativeTest' as task onlyIf 'Task is enabled' is false.
description seems straight forward, except that - I cannot for the life of me find a way to enable it via google, and then the obvious underlying question, why is this even disabled to begin with 😕
e

ephemient

05/17/2023, 6:48 AM
what architecture is your native target set up for and what is your current architecture? KGP disables tasks that don't match
r

Rohde Fischer

05/17/2023, 8:50 AM
I am currently operating on a Mac 😞 normally it’s on Linux, thinking of it, it does kind of match that last I saw it working was on my Linux. That said, the code for Mac OS seems to be there, but I don’t know if I need to do anything special with regards to the M1 architecture?
e

ephemient

05/17/2023, 6:22 PM
depends on what your configuration looks like now
if you have
kotlin {
    linuxX64("native")
then I would recommend changing that to
kotlin {
    linuxX64()
    macosX64()
    macosArm64()
although that will also require adjusting your source sets
r

Rohde Fischer

05/18/2023, 11:16 AM
I have the standard:
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.")
    }
but yeah, in that I do notice the lack of macosArm64
@ephemient finally got around to trying out with
macosArm64
, and indeed that made the difference, so now it works, thanks a lot for making me aware
s

Sebastian Sellmair [JB]

05/18/2023, 1:50 PM
@Rohde Fischer: the approach is not standard anymore, but rather outdated! Is there a reason for you not updating to hmpp? Just enable all targets and call targetHierarchy.default()
r

Rohde Fischer

05/18/2023, 5:24 PM
@Sebastian Sellmair [JB] I’m just using the template from IntelliJ, do you have a link to an updated sample?
e

ephemient

05/19/2023, 3:46 AM
I don't know if there's any updated template because I never use IntelliJ to create a new project, but following the docs at https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets etc. should lead you to a project structure closer to recommended
r

Rohde Fischer

05/19/2023, 4:28 PM
thanks a lot @ephemient and @Sebastian Sellmair [JB] always happy to improve on my setups 🙂
just to be sure I understand correctly, rather than doing this:
kotlin {
        val hostOs = System.getProperty("os.name")
        val isMingwX64 = hostOs.startsWith("Windows")
        val nativeTarget = when {
            hostOs == "Mac OS X" -> macosArm64("native")
//            hostOs == "Mac OS X" -> macosX64("native")
            hostOs == "Linux" -> linuxX64("native")
            isMingwX64 -> mingwX64("native")
            else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
        }
//...
    }
you’d in the currently do:
kotlin {
        linuxX64()
        linuxArm64()
        macosX64()
        macosArm64()
        mingwX64()
//...
    }
and then ofc add stuff like jvm, js etc. per needed?
seems to break the build, I guess a bit more than just that is needed
I’m getting:
KotlinSourceSet with name 'nativeMain' not found
e

ephemient

05/20/2023, 9:13 AM
r

Rohde Fischer

05/20/2023, 9:15 AM
thanks, just by skimming it looks exactly like what I’m looking for, trying it immediately
works like a charm 🙂 thanks again ^^