[Gradle] GetCommonizerTargetOfSourceSet: Gracefully handle common non-hmpp workaround
This commit is contained in:
+14
@@ -163,4 +163,18 @@ class SourceSetCommonizerTargetTest {
|
||||
assertNull(project.getCommonizerTarget(commonMain), "Expected commonMain to have no commonizer target")
|
||||
assertNull(project.getCommonizerTarget(commonTest), "Expected commonTest to have no commonizer target")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `nativeMain with non hmpp workaround`() {
|
||||
val linux1 = kotlin.linuxX64("linux1")
|
||||
val linux2 = kotlin.linuxArm64("linux2")
|
||||
|
||||
val nativeMain = kotlin.sourceSets.create("nativeMain")
|
||||
|
||||
listOf(linux1, linux2).forEach { target ->
|
||||
target.compilations.getByName("main").source(nativeMain)
|
||||
}
|
||||
|
||||
assertNull(project.getCommonizerTarget(nativeMain), "Expected no commonizer target, since no real source set hierarchy is given")
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -40,12 +40,13 @@ private fun Project.getLeafCommonizerTarget(sourceSet: KotlinSourceSet): LeafCom
|
||||
val konanTargets = compilationsBySourceSets(this)[sourceSet].orEmpty()
|
||||
.flatMap { compilation -> compilation.konanTargets }
|
||||
|
||||
return when {
|
||||
konanTargets.isEmpty() -> null
|
||||
konanTargets.size == 1 -> LeafCommonizerTarget(konanTargets.single())
|
||||
else -> error("Source set ${sourceSet.name} is not a leaf source set. konanTargets=$konanTargets")
|
||||
}
|
||||
return if (konanTargets.size == 1) LeafCommonizerTarget(konanTargets.single())
|
||||
|
||||
/*
|
||||
Can even be more than one, when added using `KotlinCompilation.source`. Still returning null, since this
|
||||
does not represent a 'proper' source set hierarchy
|
||||
*/
|
||||
else null
|
||||
}
|
||||
|
||||
private fun KotlinSourceSetContainer.resolveSourceSetsDirectlyDependingOn(sourceSet: KotlinSourceSet): Set<KotlinSourceSet> {
|
||||
|
||||
Reference in New Issue
Block a user