[Gradle][MPP] CommonizerHierarchicalIT: Use targetHierarchy API
^KT-53570 Verification Pending
This commit is contained in:
committed by
Space Team
parent
e84dac45d7
commit
0c114b9664
+12
-6
@@ -39,9 +39,9 @@ class CommonizerHierarchicalIT : BaseGradleIT() {
|
||||
}
|
||||
|
||||
if (Os.canCompileWindows) {
|
||||
build(":p1:compileWindowsMainKotlinMetadata") {
|
||||
build(":p1:compileMingwMainKotlinMetadata") {
|
||||
assertSuccessful()
|
||||
assertFileExists("p1/build/classes/kotlin/metadata/windowsMain/klib/p1_windowsMain.klib")
|
||||
assertFileExists("p1/build/classes/kotlin/metadata/mingwMain/klib/p1_mingwMain.klib")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@ class CommonizerHierarchicalIT : BaseGradleIT() {
|
||||
assertFileExists("p1/build/classes/kotlin/metadata/nativeMain/klib/p1_nativeMain.klib")
|
||||
assertNoDuplicateLibraryWarning()
|
||||
}
|
||||
|
||||
build(":p1:compileConcurrentMainKotlinMetadata") {
|
||||
assertSuccessful()
|
||||
assertFileExists("p1/build/classes/kotlin/metadata/concurrentMain/default")
|
||||
assertNoDuplicateLibraryWarning()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,10 +93,10 @@ class CommonizerHierarchicalIT : BaseGradleIT() {
|
||||
}
|
||||
|
||||
if (Os.canCompileWindows) {
|
||||
build(":p1:windowsX64MainKlibrary", ":p1:windowsX86MainKlibrary") {
|
||||
build(":p1:mingwX64MainKlibrary", ":p1:mingwX86MainKlibrary") {
|
||||
assertSuccessful()
|
||||
assertFileExists("p1/build/classes/kotlin/windowsX64/main/klib/p1.klib")
|
||||
assertFileExists("p1/build/classes/kotlin/windowsX86/main/klib/p1.klib")
|
||||
assertFileExists("p1/build/classes/kotlin/mingwX64/main/klib/p1.klib")
|
||||
assertFileExists("p1/build/classes/kotlin/mingwX86/main/klib/p1.klib")
|
||||
assertNoDuplicateLibraryWarning()
|
||||
}
|
||||
}
|
||||
@@ -167,7 +173,7 @@ class CommonizerHierarchicalIT : BaseGradleIT() {
|
||||
private val os = OperatingSystem.current()
|
||||
val canCompileApple get() = os.isMacOsX
|
||||
val canCompileLinux get() = os.isLinux || os.isMacOsX
|
||||
val canCompileWindows get() = os.isWindows
|
||||
val canCompileWindows get() = os.isWindows || os.isMacOsX
|
||||
}
|
||||
|
||||
private fun CompiledProject.assertNoDuplicateLibraryWarning() = assertNotContains("library included more than once")
|
||||
|
||||
+22
-57
@@ -1,20 +1,28 @@
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
|
||||
operator fun KotlinSourceSet.invoke(builder: SourceSetHierarchyBuilder.() -> Unit): KotlinSourceSet {
|
||||
SourceSetHierarchyBuilder(this).builder()
|
||||
return this
|
||||
}
|
||||
|
||||
class SourceSetHierarchyBuilder(private val node: KotlinSourceSet) {
|
||||
operator fun KotlinSourceSet.unaryMinus() = this.dependsOn(node)
|
||||
}
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
targetHierarchy.default {
|
||||
common {
|
||||
group("concurrent") {
|
||||
jvm()
|
||||
|
||||
group("native") {
|
||||
group("appleAndLinux") {
|
||||
anyApple()
|
||||
anyLinux()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
js()
|
||||
jvm()
|
||||
|
||||
@@ -24,55 +32,12 @@ kotlin {
|
||||
macosX64()
|
||||
macosArm64()
|
||||
|
||||
ios()
|
||||
|
||||
mingwX64("windowsX64")
|
||||
mingwX86("windowsX86")
|
||||
|
||||
val commonMain by sourceSets.getting
|
||||
val concurrentMain by sourceSets.creating
|
||||
val jvmMain by sourceSets.getting
|
||||
val jsMain by sourceSets.getting
|
||||
val nativeMain by sourceSets.creating
|
||||
val appleAndLinuxMain by sourceSets.creating
|
||||
val linuxMain by sourceSets.creating
|
||||
val linuxX64Main by sourceSets.getting
|
||||
val linuxArm64Main by sourceSets.getting
|
||||
val appleMain by sourceSets.creating
|
||||
val macosMain by sourceSets.creating
|
||||
val macosX64Main by sourceSets.getting
|
||||
val macosArm64Main by sourceSets.getting
|
||||
val iosMain by sourceSets.getting
|
||||
val windowsMain by sourceSets.creating
|
||||
val windowsX64Main by sourceSets.getting
|
||||
val windowsX86Main by sourceSets.getting
|
||||
|
||||
commonMain {
|
||||
-jsMain
|
||||
-concurrentMain {
|
||||
-jvmMain
|
||||
-nativeMain {
|
||||
-appleAndLinuxMain {
|
||||
-appleMain {
|
||||
-iosMain
|
||||
-macosMain {
|
||||
-macosX64Main
|
||||
-macosArm64Main
|
||||
}
|
||||
}
|
||||
-linuxMain {
|
||||
-linuxArm64Main
|
||||
-linuxX64Main
|
||||
}
|
||||
}
|
||||
-windowsMain {
|
||||
-windowsX64Main
|
||||
-windowsX86Main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
iosX64()
|
||||
iosArm64()
|
||||
iosSimulatorArm64()
|
||||
|
||||
mingwX64()
|
||||
mingwX86()
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.optIn("kotlin.RequiresOptIn")
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 ConcurrentMain {
|
||||
operator fun invoke() = println("Hello")
|
||||
}
|
||||
+1
@@ -7,6 +7,7 @@ import withPosix.getStructFromPosix
|
||||
import withPosix.getStructPointerFromPosix
|
||||
|
||||
object NativeMain {
|
||||
val concurrentMainInvocation = ConcurrentMain.invoke()
|
||||
val structFromPosix = getStructFromPosix()
|
||||
val structPointerFromPosix = getStructPointerFromPosix()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user