CInteropProcess: Promote settings to constructor

This enforces that the specified c-interop settings cannot be re-set on
a CInteropProcess.
This commit is contained in:
sebastian.sellmair
2021-03-10 10:22:56 +01:00
committed by Space
parent be84b7b419
commit 7cf8e9ec58
2 changed files with 3 additions and 6 deletions
@@ -298,8 +298,7 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
private fun Project.createCInteropTasks(compilation: KotlinNativeCompilation) {
compilation.cinterops.all { interop ->
val interopTask = registerTask<CInteropProcess>(interop.interopProcessingTaskName) {
it.settings = interop
val interopTask = registerTask<CInteropProcess>(interop.interopProcessingTaskName, listOf(interop)) {
it.destinationDir = provider { klibOutputDirectory(compilation).resolve("cinterop") }
it.group = INTEROP_GROUP
it.description = "Generates Kotlin/Native interop library '${interop.name}' " +
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.library.*
import java.io.File
import java.nio.charset.StandardCharsets
import java.security.MessageDigest
import javax.inject.Inject
import org.jetbrains.kotlin.konan.file.File as KFile
import org.jetbrains.kotlin.util.Logger as KLogger
@@ -921,10 +922,7 @@ internal class CacheBuilder(val project: Project, val binary: NativeBinary, val
}
}
open class CInteropProcess : DefaultTask() {
@Internal
lateinit var settings: DefaultCInteropSettings
open class CInteropProcess @Inject constructor(@get:Internal val settings: DefaultCInteropSettings) : DefaultTask() {
@Internal // Taken into account in the outputFileProvider property
lateinit var destinationDir: Provider<File>