[Gradle] CInteropCommonizerDependent: Implement 'fromAssociateCompilations'
This additional API and changes in CInteropCommonizerDependencies.kt will make sure, that test source sets will still receive commonization results, even when the exact targets are not requested by any of the main source sets. ^KT-48138 Verification Pending
This commit is contained in:
committed by
Space
parent
9a39b1f4d1
commit
3625c953ae
+3
-9
@@ -46,16 +46,10 @@ private fun Project.setupCInteropCommonizerDependenciesForIde(sourceSet: Default
|
||||
val cinteropCommonizerTask = project.copyCommonizeCInteropForIdeTask ?: return
|
||||
|
||||
addDependency(sourceSet, filesProvider files@{
|
||||
val sourceSetCommonizerTarget = getCommonizerTarget(sourceSet)
|
||||
val directlyDependent = CInteropCommonizerDependent.from(project, sourceSet)
|
||||
val associateDependent = CInteropCommonizerDependent.fromAssociateCompilations(project, sourceSet)
|
||||
|
||||
val additionalVisibleSourceSets = sourceSet.getAdditionalVisibleSourceSets()
|
||||
.filter { sourceSet -> getCommonizerTarget(sourceSet) == sourceSetCommonizerTarget }
|
||||
|
||||
val cinteropCommonizerDependents = (additionalVisibleSourceSets + sourceSet).toSet()
|
||||
.mapNotNull { sourceSet -> CInteropCommonizerDependent.from(this, sourceSet) }
|
||||
.toSet()
|
||||
|
||||
cinteropCommonizerDependents.map { cinteropCommonizerDependent ->
|
||||
listOfNotNull(directlyDependent, associateDependent).map { cinteropCommonizerDependent ->
|
||||
cinteropCommonizerTask.get().commonizedOutputLibraries(cinteropCommonizerDependent)
|
||||
}
|
||||
})
|
||||
|
||||
+13
@@ -92,6 +92,19 @@ internal fun CInteropCommonizerDependent.Factory.from(project: Project, sourceSe
|
||||
)
|
||||
}
|
||||
|
||||
internal fun CInteropCommonizerDependent.Factory.fromAssociateCompilations(
|
||||
project: Project, sourceSet: KotlinSourceSet
|
||||
): CInteropCommonizerDependent? {
|
||||
return from(
|
||||
target = project.getCommonizerTarget(sourceSet) as? SharedCommonizerTarget ?: return null,
|
||||
compilations = (compilationsBySourceSets(project)[sourceSet] ?: return null)
|
||||
.filterIsInstance<KotlinNativeCompilation>()
|
||||
.flatMap { compilation -> compilation.associateWithTransitiveClosure }
|
||||
.filterIsInstance<KotlinNativeCompilation>()
|
||||
.toSet()
|
||||
)
|
||||
}
|
||||
|
||||
private fun KotlinSharedNativeCompilation.findDependingNativeCompilations(): Set<KotlinNativeCompilation> {
|
||||
val multiplatformExtension = project.multiplatformExtensionOrNull ?: return emptySet()
|
||||
val allParticipatingSourceSetsOfCompilation = allParticipatingSourceSets()
|
||||
|
||||
+5
-3
@@ -5,11 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.targets.native.internal
|
||||
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.commonizer.CommonizerDependency
|
||||
import org.jetbrains.kotlin.commonizer.NonTargetedCommonizerDependency
|
||||
import org.jetbrains.kotlin.commonizer.TargetedCommonizerDependency
|
||||
import org.jetbrains.kotlin.commonizer.allLeaves
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCliCommonizer
|
||||
@@ -142,7 +140,11 @@ internal open class CInteropCommonizerTask : AbstractCInteropCommonizerTask() {
|
||||
.mapNotNull { sourceSet -> CInteropCommonizerDependent.from(project, sourceSet) }
|
||||
.toSet()
|
||||
|
||||
return (fromSharedNativeCompilations + fromSourceSets)
|
||||
val fromSourceSetsAssociateCompilations = multiplatformExtension.sourceSets
|
||||
.mapNotNull { sourceSet -> CInteropCommonizerDependent.fromAssociateCompilations(project, sourceSet) }
|
||||
.toSet()
|
||||
|
||||
return (fromSharedNativeCompilations + fromSourceSets + fromSourceSetsAssociateCompilations)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user