提交 a0557ad9 编写于 作者: S sebastian.sellmair 提交者: Space

CommonizerIT: Implement `test commonizeInterop using posix APIs`

^KT-45497
上级 7f9fe6b3
......@@ -207,6 +207,27 @@ class CommonizerIT : BaseGradleIT() {
}
}
@Test
fun `test commonizeInterop using posix APIs`() {
with(preparedProject("commonizeInteropUsingPosixApis")) {
build(":commonizeCInterop") {
assertSuccessful()
assertTasksExecuted(":cinteropWithPosixTargetA")
assertTasksExecuted(":cinteropWithPosixTargetB")
assertTasksExecuted(":commonizeNativeDistribution")
assertTasksExecuted(":commonizeCInterop")
}
build(":compileNativeMainKotlinMetadata") {
assertSuccessful()
assertTasksUpToDate(":cinteropWithPosixTargetA")
assertTasksUpToDate(":cinteropWithPosixTargetB")
assertTasksUpToDate(":commonizeNativeDistribution")
assertTasksUpToDate(":commonizeCInterop")
}
}
}
private fun preparedProject(name: String): Project {
return Project(name).apply {
setupWorkingDir()
......
plugins {
kotlin("multiplatform")
}
repositories {
mavenLocal()
mavenCentral()
}
kotlin {
val targetA = <targetA>("targetA")
val targetB = <targetB>("targetB")
val commonMain by sourceSets.getting
val nativeMain by sourceSets.creating
val targetAMain by sourceSets.getting
val targetBMain by sourceSets.getting
nativeMain.dependsOn(commonMain)
targetAMain.dependsOn(nativeMain)
targetBMain.dependsOn(nativeMain)
sourceSets.all {
languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
}
targetA.compilations.getByName("main").cinterops.create("withPosix") {
header(file("libs/withPosix.h"))
}
targetB.compilations.getByName("main").cinterops.create("withPosix") {
header(file("libs/withPosix.h"))
}
}
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.enableCInteropCommonization=true
kotlin.native.enableDependencyPropagation=false
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
val kotlin_version: String by settings
plugins {
kotlin("multiplatform").version(kotlin_version)
}
}
import kotlinx.cinterop.useContents
import platform.posix.stat
import withPosix.getFileStat
fun main() {
repeat(10) {
getFileStat().useContents { score(this) }
}
}
expect fun score(stat: stat): Int
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册