[Commonizer] Implement safe SharedCommonizerTarget factory function
Do not try to instantiate SharedCommonizerTarget with no leaves ^KT-45350 Verification Pending
This commit is contained in:
committed by
Space
parent
6527452143
commit
3d6893e518
+7
-1
@@ -29,8 +29,14 @@ public data class SharedCommonizerTarget(val targets: Set<CommonizerTarget>) : C
|
|||||||
public constructor(vararg targets: KonanTarget) : this(targets.toSet())
|
public constructor(vararg targets: KonanTarget) : this(targets.toSet())
|
||||||
public constructor(targets: Iterable<KonanTarget>) : this(targets.map(::LeafCommonizerTarget).toSet())
|
public constructor(targets: Iterable<KonanTarget>) : this(targets.map(::LeafCommonizerTarget).toSet())
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
public fun ifNotEmpty(targets: Set<CommonizerTarget>): SharedCommonizerTarget? {
|
||||||
|
return if (targets.isNotEmpty()) SharedCommonizerTarget(targets) else null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
require(targets.isNotEmpty())
|
require(targets.isNotEmpty()) { "Empty 'SharedCommonizerTarget': Expected at least one target" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -117,7 +117,10 @@ internal class NativeDistributionCommonize(options: Collection<Option<*>>) : Tas
|
|||||||
)
|
)
|
||||||
if (copyStdlib) this add CopyStdlibResultsConsumer(distribution, destination, progressLogger)
|
if (copyStdlib) this add CopyStdlibResultsConsumer(distribution, destination, progressLogger)
|
||||||
if (copyEndorsedLibs) this add CopyEndorsedLibrairesResultsConsumer(distribution, destination, progressLogger)
|
if (copyEndorsedLibs) this add CopyEndorsedLibrairesResultsConsumer(distribution, destination, progressLogger)
|
||||||
this add LoggingResultsConsumer(SharedCommonizerTarget(existingTargets), progressLogger)
|
|
||||||
|
SharedCommonizerTarget.ifNotEmpty(existingTargets)?.let { sharedTargetForLogger ->
|
||||||
|
this add LoggingResultsConsumer(sharedTargetForLogger, progressLogger)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val targetNames = commonizerTargets.joinToString { it.prettyName }
|
val targetNames = commonizerTargets.joinToString { it.prettyName }
|
||||||
|
|||||||
Reference in New Issue
Block a user