https://kotlinlang.org logo
p

pardom

06/09/2020, 1:44 PM
I would use that set to filter this:
Copy code
targets {
    presets
        .filterIsInstance<AbstractKotlinNativeTargetPreset<*>>()
        .filter { it in supportedTargets }
        .forEach { preset ->
            targetFromPreset(preset, preset.name) {
                compilations["main"].source(sourceSets["nativeMain"])
                compilations["test"].source(sourceSets["nativeTest"])
            }
        }
}
r

russhwolf

06/09/2020, 1:46 PM
I tried to do this once and couldn't find a way to make it work, but interested if anyone else has figured it out.
k

Kris Wong

06/09/2020, 1:50 PM
take it out of the
targets
block, directly in the
kotlin
block. it seems valid, though I haven't tried to verify it works properly.
r

russhwolf

06/09/2020, 1:58 PM
That code snippet is fine. The hard part is figuring out how to infer the list of
supportedTargets
by inspecting your dependencies.
☝🏼 1
k

Kris Wong

06/09/2020, 1:59 PM
i see
p

pardom

08/17/2020, 5:30 PM
Follow up: I write a script to print the supported native targets of an artifact. It works for my purposes, but depends on Maven Central. It's not a complete solution, but saves me some time: https://github.com/oolong-kt/oolong/pull/106/files#diff-2ad7cff1ee7e009affe9ee2a99b6c0d5