[MPP] Add IT for cinterop commonization
KT-54975
This commit is contained in:
committed by
Space Team
parent
7e2a7579e8
commit
8bdd9b3837
+71
-4
@@ -11,10 +11,7 @@ import org.jetbrains.kotlin.commonizer.identityString
|
|||||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinBinaryDependency
|
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinBinaryDependency
|
||||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinDependency
|
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinDependency
|
||||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinResolvedBinaryDependency
|
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinResolvedBinaryDependency
|
||||||
import org.jetbrains.kotlin.gradle.idea.tcs.extras.isCommonized
|
import org.jetbrains.kotlin.gradle.idea.tcs.extras.*
|
||||||
import org.jetbrains.kotlin.gradle.idea.tcs.extras.isNativeDistribution
|
|
||||||
import org.jetbrains.kotlin.gradle.idea.tcs.extras.isNativeStdlib
|
|
||||||
import org.jetbrains.kotlin.gradle.idea.tcs.extras.klibExtra
|
|
||||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.assertMatches
|
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.assertMatches
|
||||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.binaryCoordinates
|
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.binaryCoordinates
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
@@ -85,4 +82,74 @@ class MppIdeDependencyResolutionIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GradleTest
|
||||||
|
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) {
|
||||||
|
build(":dep-with-cinterop:publishToMavenLocal")
|
||||||
|
// build(":prepareKotlinIdeaImport")
|
||||||
|
// build("copyCommonizeCInteropForIde")
|
||||||
|
// build(":clientForBinaryDep:transformCommonMainCInteropDependenciesMetadataForIde")
|
||||||
|
|
||||||
|
resolveIdeDependencies("dep-with-cinterop") { dependencies ->
|
||||||
|
val commonMainDependencies = dependencies["commonMain"].cinteropDependencies()
|
||||||
|
val commonTestDependencies = dependencies["commonTest"].cinteropDependencies()
|
||||||
|
val linuxX64MainDependencies = dependencies["linuxX64Main"].cinteropDependencies()
|
||||||
|
val linuxX64TestDependencies = dependencies["linuxX64Test"].cinteropDependencies()
|
||||||
|
val linuxArmMainDependencies = dependencies["linuxArm64Main"].cinteropDependencies()
|
||||||
|
val linuxArmTestDependencies = dependencies["linuxArm64Test"].cinteropDependencies()
|
||||||
|
|
||||||
|
for (commonDeps in listOf(commonMainDependencies, commonTestDependencies)) {
|
||||||
|
commonDeps.assertMatches(binaryCoordinates(Regex("a:dep.*linux_arm64, linux_x64")))
|
||||||
|
}
|
||||||
|
|
||||||
|
linuxX64MainDependencies.assertMatches(binaryCoordinates(Regex("a:dep.*linux_x64")))
|
||||||
|
linuxArmMainDependencies.assertMatches(binaryCoordinates(Regex("a:dep.*linux_arm64")))
|
||||||
|
// TODO (kirpichenkov): cinterops from associate compilations for platform source sets
|
||||||
|
linuxX64TestDependencies.assertMatches(/*binaryCoordinates(Regex("a:dep.*linux_x64"))*/)
|
||||||
|
linuxArmTestDependencies.assertMatches(/*binaryCoordinates(Regex("a:dep.*linux_arm64"))*/)
|
||||||
|
}
|
||||||
|
|
||||||
|
resolveIdeDependencies("client-for-binary-dep") { dependencies ->
|
||||||
|
val commonMainDependencies = dependencies["commonMain"].cinteropDependencies()
|
||||||
|
val commonTestDependencies = dependencies["commonTest"].cinteropDependencies()
|
||||||
|
val linuxMainDependencies = dependencies["linuxX64Main"].cinteropDependencies()
|
||||||
|
val linuxTestDependencies = dependencies["linuxX64Test"].cinteropDependencies()
|
||||||
|
val linux2MainDependencies = dependencies["linuxArm64Main"].cinteropDependencies()
|
||||||
|
val linux2TestDependencies = dependencies["linuxArm64Test"].cinteropDependencies()
|
||||||
|
|
||||||
|
for (commonDeps in listOf(commonMainDependencies, commonTestDependencies)) {
|
||||||
|
commonDeps.assertMatches(
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (platformDeps in listOf(linuxMainDependencies, linuxTestDependencies, linux2MainDependencies, linux2TestDependencies)) {
|
||||||
|
platformDeps.assertMatches(
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resolveIdeDependencies("client-for-project-to-project-dep") { dependencies ->
|
||||||
|
val commonMainDependencies = dependencies["commonMain"].cinteropDependencies()
|
||||||
|
val commonTestDependencies = dependencies["commonTest"].cinteropDependencies()
|
||||||
|
val linuxMainDependencies = dependencies["linuxX64Main"].cinteropDependencies()
|
||||||
|
val linuxTestDependencies = dependencies["linuxX64Test"].cinteropDependencies()
|
||||||
|
val linux2MainDependencies = dependencies["linuxArm64Main"].cinteropDependencies()
|
||||||
|
val linux2TestDependencies = dependencies["linuxArm64Test"].cinteropDependencies()
|
||||||
|
|
||||||
|
for (commonDeps in listOf(commonMainDependencies, commonTestDependencies)) {
|
||||||
|
commonDeps.assertMatches(binaryCoordinates(Regex("a:dep.*linux_arm64, linux_x64")))
|
||||||
|
}
|
||||||
|
|
||||||
|
for (platformDeps in listOf(linuxMainDependencies, linuxTestDependencies, linux2MainDependencies, linux2TestDependencies)) {
|
||||||
|
platformDeps.assertMatches() // TODO (kirpichenkov): project to project dependency, platform source set cinterops
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
allprojects {
|
||||||
|
group = "a"
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
linuxX64()
|
||||||
|
linuxArm64()
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
getByName("commonMain").dependencies {
|
||||||
|
implementation("a:dep-with-cinterop:1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
id("maven-publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
group = "a"
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
linuxX64()
|
||||||
|
linuxArm64()
|
||||||
|
|
||||||
|
sourceSets.getByName("commonMain").dependencies {
|
||||||
|
implementation(project(":dep-with-cinterop"))
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
id("maven-publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
linuxX64().compilations.getByName("main").cinterops.create("dep")
|
||||||
|
linuxArm64().compilations.getByName("main").cinterops.create("dep")
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
typedef enum {
|
||||||
|
BEE,
|
||||||
|
GOO
|
||||||
|
} Dependency;
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package pkg
|
||||||
|
|
||||||
|
import dep.*
|
||||||
|
|
||||||
|
class DependencyKotlinClass {
|
||||||
|
val mode: Dependency = Dependency.GOO
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
headers = dep/dependency.h
|
||||||
|
compilerOpts = -Ilibs/include
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
kotlin.mpp.import.enableKgpDependencyResolution=true
|
||||||
|
kotlin.mpp.enableCInteropCommonization=true
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
rootProject.name = "cinterops"
|
||||||
|
|
||||||
|
include(":dep-with-cinterop")
|
||||||
|
include(":client-for-binary-dep")
|
||||||
|
include(":client-for-project-to-project-dep")
|
||||||
Reference in New Issue
Block a user