[Gradle] Implement MppCompositeBuildIT for KT-37051 (with cinterop)

^KT-37051 Verification Pending
This commit is contained in:
Sebastian Sellmair
2023-02-01 16:31:39 +01:00
committed by Space Team
parent 8a62523ffc
commit 5a14c11ae7
16 changed files with 191 additions and 0 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.gradle.mpp
import org.gradle.api.logging.configuration.WarningMode
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.KOTLIN_VERSION
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinSourceDependency.Type.Regular
@@ -235,4 +236,21 @@ class MppCompositeBuildIT : KGPBaseTest() {
}
}
}
@GradleTest
fun `test - sample4-KT-37051-withCInterop`(gradleVersion: GradleVersion) {
val producer = project("mpp-composite-build/sample4-KT-37051-withCInterop/producerBuild", gradleVersion)
project(
"mpp-composite-build/sample4-KT-37051-withCInterop/consumerBuild", gradleVersion,
buildOptions = defaultBuildOptions.copy(warningMode = WarningMode.Fail)
) {
settingsGradleKts.toFile().replaceText("<producer_path>", producer.projectPath.toUri().path)
build(":consumerA:assemble") {
assertTasksExecuted(":consumerA:compileKotlinLinuxX64")
assertOutputDoesNotContain("w: duplicate library")
}
}
}
}
@@ -0,0 +1,24 @@
@file:Suppress("OPT_IN_USAGE")
plugins {
kotlin("multiplatform")
}
kotlin {
targetHierarchy.default()
jvm()
linuxX64()
linuxArm64()
sourceSets.commonMain.get().dependencies {
implementation("org.jetbrains.sample:producerA:1.0.0-SNAPSHOT")
}
targets.all {
compilations.all {
compilerOptions.configure {
allWarningsAsErrors.set(true)
}
}
}
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2023 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.
*/
object ConsumerACommon {
init {
ProducerACommonX
}
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2023 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.
*/
import clib.myCFunction
object ConsumerALinuxX64 {
init {
ProducerACommonX
ProducerANative
ProducerALinuxX64
myCFunction()
}
}
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2023 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.
*/
import kotlinx.cinterop.memScoped
import platform.posix.fopen
object ConsumerANative {
init {
memScoped { }
fopen("", "")
ProducerANative
}
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2023 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.
*/
object ConsumerACommon {
init {
ProducerACommonX
}
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2023 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.
*/
import clib.myCFunction
object ConsumerALinuxX64 {
init {
ProducerACommonX
ProducerANative
ProducerALinuxX64
myCFunction()
}
}
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2023 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.
*/
import kotlinx.cinterop.memScoped
import platform.posix.fopen
object ConsumerANative {
init {
memScoped { }
fopen("", "")
ProducerANative
}
}
@@ -0,0 +1,14 @@
dependencyResolutionManagement {
repositories {
mavenLocal()
mavenCentral()
}
}
include(":consumerA")
includeBuild("<producer_path>") {
dependencySubstitution {
substitute(module("org.jetbrains.sample:producerA")).using(project(":producerA"))
}
}
@@ -0,0 +1,25 @@
@file:Suppress("OPT_IN_USAGE")
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
`maven-publish`
}
group = "org.jetbrains.sample"
version = "1.0.0-SNAPSHOT"
kotlin {
targetHierarchy.default()
jvm()
linuxX64()
linuxArm64()
targets.withType<KotlinNativeTarget>().all {
compilations.getByName("main").cinterops.create("clib") {
header("src/clib.h")
}
}
}
@@ -0,0 +1,7 @@
/*
* Copyright 2010-2023 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.
*/
object ProducerACommonX
object A
@@ -0,0 +1,6 @@
/*
* Copyright 2010-2023 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.
*/
object ProducerALinuxX64
@@ -0,0 +1,6 @@
/*
* Copyright 2010-2023 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.
*/
object ProducerANative
@@ -0,0 +1,8 @@
dependencyResolutionManagement {
repositories {
mavenLocal()
mavenCentral()
}
}
include(":producerA")