[Gradle][MPP] Implement test ^KT-50847 missing cinterop in supported target
This commit is contained in:
committed by
Space
parent
f5ec168b89
commit
5e931a3039
+19
@@ -656,6 +656,25 @@ class CommonizerIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test KT-50847 missing cinterop in supported target`() {
|
||||||
|
with(Project("commonize-kt-50847-cinterop-missing-in-supported-target")) {
|
||||||
|
build(":compileCommonMainKotlinMetadata", "-PdisableTargetNumber=1") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksSkipped(":cinteropSimpleTarget1")
|
||||||
|
assertTasksExecuted(":cinteropSimpleTarget2")
|
||||||
|
assertTasksExecuted(":commonizeCInterop")
|
||||||
|
}
|
||||||
|
|
||||||
|
build(":compileCommonMainKotlinMetadata", "-PdisableTargetNumber=2") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksSkipped(":cinteropSimpleTarget2")
|
||||||
|
assertTasksExecuted(":cinteropSimpleTarget1")
|
||||||
|
assertTasksExecuted(":commonizeCInterop")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun preparedProject(name: String): Project {
|
private fun preparedProject(name: String): Project {
|
||||||
return Project(name).apply {
|
return Project(name).apply {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
|
|||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
val linuxTarget1 = linuxArm64("target1")
|
||||||
|
val linuxTarget2 = linuxX64("target2")
|
||||||
|
|
||||||
|
val targets = listOf(linuxTarget1, linuxTarget2)
|
||||||
|
|
||||||
|
/* This test only makes sense if all targets ar 'officially supported' */
|
||||||
|
targets.forEach { target ->
|
||||||
|
if (!HostManager().isEnabled(target.konanTarget)) {
|
||||||
|
error("Expected all targets in this test to be enabled. ${target.konanTarget} is not supported.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Defining a cinterop on all targets */
|
||||||
|
targets.map { it.compilations.getByName("main") }.forEach { compilation ->
|
||||||
|
compilation.cinterops.create("simple") {
|
||||||
|
header(file("src/nativeInterop/cinterop/simple.h"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 'Disable' a cinterop on a certain target */
|
||||||
|
val disabledCInteropTarget = when (val propertyValue = properties["disableTargetNumber"]) {
|
||||||
|
null -> error("Test project expects property 'disableTargetNumber' with value '1' or '2'")
|
||||||
|
"1" -> linuxTarget1
|
||||||
|
"2" -> linuxTarget2
|
||||||
|
else -> error("Unexpected value for property 'disableTargetNumber' ($propertyValue) expected '1' or '2'")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named(disabledCInteropTarget.compilations.getByName("main").cinterops.single().interopProcessingTaskName)
|
||||||
|
.configure { enabled = false }
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
kotlin.mpp.enableCInteropCommonization=true
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import simple.simpleInteropFunction
|
||||||
|
|
||||||
|
fun main() = simpleInteropFunction()
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
void simpleInteropFunction();
|
||||||
Reference in New Issue
Block a user