All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.co.touchlab.skie.plugin.switflink.SwiftUnpackingConfigurator.kt Maven / Gradle / Ivy

There is a newer version: 0.9.0-RC.5
Show newest version
package co.touchlab.skie.plugin.switflink

import co.touchlab.skie.plugin.SkieTarget
import co.touchlab.skie.plugin.skieBuildDirectory
import co.touchlab.skie.plugin.util.registerSkieTargetBasedTask
import co.touchlab.skie.util.file.isKlib

object SwiftUnpackingConfigurator {

    fun configureCustomSwiftUnpacking(target: SkieTarget) {
        val unpackTask = target.registerSkieTargetBasedTask("unpackSwiftSources") {
            val linkerKlibs = target.linkerConfiguration.fileCollection { true }.filter { it.isKlib }
            klibs.from(linkerKlibs)

            if (target is SkieTarget.Binary) {
                val currentModuleKlib = target.compilationProvider.map { it.compileTaskOutputFileProvider }

                klibs.from(currentModuleKlib)
                // Needed because the klib is a plain Java file
                dependsOn(target.compilationProvider.flatMap { it.compileTaskProvider })
            }

            val bundledSwiftDirectory = target.skieBuildDirectory.map { it.swift.bundled.directory }
            output.set(bundledSwiftDirectory)
        }

        val unpackTaskOutput = unpackTask.flatMap { it.output }

        target.task.configure {
            inputs.files(unpackTaskOutput)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy