Implement CInteropIdentifier.Scope

This commit is contained in:
sebastian.sellmair
2021-03-10 09:43:25 +01:00
committed by Space
parent 6efd04edc0
commit a53df56781
4 changed files with 34 additions and 8 deletions
@@ -44,7 +44,7 @@ open class DefaultCInteropSettings @Inject constructor(
override fun getName(): String = name
internal val identifier: CInteropIdentifier
get() = CInteropIdentifier(compilation.compileKotlinTaskName, name)
get() = CInteropIdentifier(CInteropIdentifier.Scope.create(compilation), name)
val target: KotlinNativeTarget
get() = compilation.target
@@ -226,5 +226,3 @@ private fun Project.getDependingNativeCompilations(compilation: KotlinSharedNati
.filter { nativeCompilation -> nativeCompilation.allParticipatingSourceSets().containsAll(allParticipatingSourceSetsOfCompilation) }
.toSet()
}
@@ -6,15 +6,34 @@
package org.jetbrains.kotlin.gradle.targets.native.internal
import org.gradle.api.tasks.Input
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.utils.UnsafeApi
import java.io.Serializable
/**
* Project unique identifier for all cinterops
*/
data class CInteropIdentifier internal constructor(
val compilationTaskName: String,
val cinteropName: String
) {
internal data class CInteropIdentifier internal constructor(
val scope: Scope,
val interopName: String
) : Serializable {
class Scope @UnsafeApi internal constructor(val name: String) : Serializable {
companion object {
@OptIn(UnsafeApi::class)
fun create(compilation: KotlinCompilation<*>): Scope {
return Scope("compilation/${compilation.compileKotlinTaskName}")
}
}
override fun toString(): String = name
override fun hashCode(): Int = name.hashCode()
override fun equals(other: Any?): Boolean {
if (other !is Scope) return false
return this.name == other.name
}
}
@get:Input
val uniqueName: String = "cinterop:$compilationTaskName/$cinteropName"
val uniqueName: String = "cinterop:${scope.name}/$interopName"
override fun toString(): String = uniqueName
}
@@ -0,0 +1,9 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.utils
@RequiresOptIn("Unsafe API. Please use safe counterpart", level = RequiresOptIn.Level.ERROR)
internal annotation class UnsafeApi