[MPP] use commonizerNativeTargets in names of propagated cinterops
KTIJ-24573
This commit is contained in:
committed by
Space Team
parent
ac8d5a0ea8
commit
8d62e488fe
+22
-5
@@ -19,7 +19,9 @@ import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.binaryCoordinates
|
|||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.jetbrains.kotlin.gradle.util.kotlinNativeDistributionDependencies
|
import org.jetbrains.kotlin.gradle.util.kotlinNativeDistributionDependencies
|
||||||
import org.jetbrains.kotlin.gradle.util.resolveIdeDependencies
|
import org.jetbrains.kotlin.gradle.util.resolveIdeDependencies
|
||||||
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
import org.junit.AssumptionViolatedException
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -91,11 +93,6 @@ class MppIdeDependencyResolutionIT : KGPBaseTest() {
|
|||||||
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testCinterops(gradleVersion: GradleVersion) {
|
fun testCinterops(gradleVersion: GradleVersion) {
|
||||||
fun Iterable<IdeaKotlinDependency>.cinteropDependencies() =
|
|
||||||
this.filterIsInstance<IdeaKotlinBinaryDependency>().filter {
|
|
||||||
it.klibExtra?.isInterop == true && !it.isNativeStdlib && !it.isNativeDistribution
|
|
||||||
}
|
|
||||||
|
|
||||||
project(projectName = "cinteropImport", gradleVersion = gradleVersion) {
|
project(projectName = "cinteropImport", gradleVersion = gradleVersion) {
|
||||||
build(":dep-with-cinterop:publishAllPublicationsToBuildRepository")
|
build(":dep-with-cinterop:publishAllPublicationsToBuildRepository")
|
||||||
|
|
||||||
@@ -245,4 +242,24 @@ class MppIdeDependencyResolutionIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GradleTest
|
||||||
|
fun `test cinterops - commonized interop name should include targets unsupported on host`(gradleVersion: GradleVersion) {
|
||||||
|
if (HostManager.hostIsMac) {
|
||||||
|
throw AssumptionViolatedException("Host shouldn't support ios target")
|
||||||
|
}
|
||||||
|
|
||||||
|
project("cinterop-ios", gradleVersion) {
|
||||||
|
resolveIdeDependencies { dependencies ->
|
||||||
|
dependencies["commonMain"].cinteropDependencies().assertMatches(
|
||||||
|
binaryCoordinates(Regex("""a:cinterop-ios-cinterop-myinterop.*\(ios_x64, linux_x64\)"""))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Iterable<IdeaKotlinDependency>.cinteropDependencies() =
|
||||||
|
this.filterIsInstance<IdeaKotlinBinaryDependency>().filter {
|
||||||
|
it.klibExtra?.isInterop == true && !it.isNativeStdlib && !it.isNativeDistribution
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
group = "a"
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
iosX64 {
|
||||||
|
compilations.getByName("main") {
|
||||||
|
cinterops {
|
||||||
|
create("myinterop") {
|
||||||
|
headers("libs/include/myinterop.h")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
linuxX64 {
|
||||||
|
compilations.getByName("main") {
|
||||||
|
cinterops {
|
||||||
|
create("myinterop") {
|
||||||
|
headers("libs/include/myinterop.h")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
kotlin.mpp.enableCInteropCommonization=true
|
||||||
|
kotlin.mpp.import.enableKgpDependencyResolution=true
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "cinterop-ios"
|
||||||
+2
-1
@@ -38,6 +38,7 @@ private fun Project.createCinteropLibraryDependency(libraryFile: java.io.File):
|
|||||||
}
|
}
|
||||||
|
|
||||||
val (group, module) = cinteropGroupAndModule(library)
|
val (group, module) = cinteropGroupAndModule(library)
|
||||||
|
val libraryTargets = library.commonizerNativeTargets ?: library.nativeTargets
|
||||||
|
|
||||||
return IdeaKotlinResolvedBinaryDependency(
|
return IdeaKotlinResolvedBinaryDependency(
|
||||||
binaryType = IdeaKotlinBinaryDependency.KOTLIN_COMPILE_BINARY_TYPE,
|
binaryType = IdeaKotlinBinaryDependency.KOTLIN_COMPILE_BINARY_TYPE,
|
||||||
@@ -46,7 +47,7 @@ private fun Project.createCinteropLibraryDependency(libraryFile: java.io.File):
|
|||||||
group = group,
|
group = group,
|
||||||
module = module,
|
module = module,
|
||||||
version = null, // TODO (kirpichenkov): if/when used for published cinterops, should be set up correctly
|
version = null, // TODO (kirpichenkov): if/when used for published cinterops, should be set up correctly
|
||||||
sourceSetName = library.nativeTargets.singleOrNull() ?: library.nativeTargets.joinToString(prefix = "(", postfix = ")")
|
sourceSetName = libraryTargets.singleOrNull() ?: libraryTargets.joinToString(prefix = "(", postfix = ")")
|
||||||
),
|
),
|
||||||
).apply {
|
).apply {
|
||||||
klibExtra = KlibExtra(library)
|
klibExtra = KlibExtra(library)
|
||||||
|
|||||||
Reference in New Issue
Block a user