when running native/multiplatform it seems that my...
# gradle
r
when running native/multiplatform it seems that my test tasks are not reached, I just get a:
Copy code
> 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
what architecture is your native target set up for and what is your current architecture? KGP disables tasks that don't match
r
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
depends on what your configuration looks like now
if you have
Copy code
kotlin {
    linuxX64("native")
then I would recommend changing that to
Copy code
kotlin {
    linuxX64()
    macosX64()
    macosArm64()
although that will also require adjusting your source sets
r
I have the standard:
Copy code
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
@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
@Sebastian Sellmair [JB] I’m just using the template from IntelliJ, do you have a link to an updated sample?
e
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
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:
Copy code
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:
Copy code
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:
Copy code
KotlinSourceSet with name 'nativeMain' not found
e
r
thanks, just by skimming it looks exactly like what I’m looking for, trying it immediately
works like a charm 🙂 thanks again ^^