p

    pardom

    2 years ago
    I would use that set to filter this:
    targets {
        presets
            .filterIsInstance<AbstractKotlinNativeTargetPreset<*>>()
            .filter { it in supportedTargets }
            .forEach { preset ->
                targetFromPreset(preset, preset.name) {
                    compilations["main"].source(sourceSets["nativeMain"])
                    compilations["test"].source(sourceSets["nativeTest"])
                }
            }
    }
    russhwolf

    russhwolf

    2 years ago
    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.
    Kris Wong

    Kris Wong

    2 years ago
    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.
    russhwolf

    russhwolf

    2 years ago
    That code snippet is fine. The hard part is figuring out how to infer the list of
    supportedTargets
    by inspecting your dependencies.
    Kris Wong

    Kris Wong

    2 years ago
    i see
    p

    pardom

    2 years ago
    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