[commonizer] Support commonizing includedForwardDeclarations in manifest

It is a new manifest property which is used only in K2, and it is
required for correct K2 processing of forward declarations.

^KT-59132
This commit is contained in:
Pavel Kunyavskiy
2023-06-26 13:54:12 +02:00
committed by Space Team
parent f3a7312ee6
commit b28b0e70b6
3 changed files with 10 additions and 0 deletions
@@ -68,6 +68,8 @@ internal class CommonNativeManifestDataProvider(
packageFqName = rawManifests.first().packageFqName,
exportForwardDeclarations = if (isInterop) rawManifests.map { it.exportForwardDeclarations }
.reduce { acc, list -> acc.intersect(list).toList() } else emptyList(),
includedForwardDeclarations = if (isInterop) rawManifests.map { it.includedForwardDeclarations }
.reduce { acc, list -> acc.intersect(list).toList() } else emptyList(),
nativeTargets = rawManifests.flatMapTo(mutableSetOf()) { it.nativeTargets },
shortName = rawManifests.first().shortName,
commonizerTarget = target
@@ -22,6 +22,7 @@ data class NativeSensitiveManifestData(
val isInterop: Boolean,
val packageFqName: String?,
val exportForwardDeclarations: List<String>,
val includedForwardDeclarations: List<String>,
val nativeTargets: Collection<String>,
val shortName: String?,
val commonizerTarget: CommonizerTarget?,
@@ -35,6 +36,7 @@ data class NativeSensitiveManifestData(
isInterop = library.isInterop,
packageFqName = library.packageFqName,
exportForwardDeclarations = library.exportForwardDeclarations,
includedForwardDeclarations = library.includedForwardDeclarations,
nativeTargets = library.nativeTargets,
shortName = library.shortName,
commonizerTarget = library.commonizerTarget?.let(::parseCommonizerTargetOrNull),
@@ -62,6 +64,10 @@ fun BaseWriterImpl.addManifest(manifest: NativeSensitiveManifestData) {
manifest.exportForwardDeclarations.sorted().joinToString(" ")
}
addOptionalProperty(KLIB_PROPERTY_INCLUDED_FORWARD_DECLARATIONS, manifest.includedForwardDeclarations.isNotEmpty() || manifest.isInterop) {
manifest.includedForwardDeclarations.sorted().joinToString(" ")
}
addOptionalProperty(KLIB_PROPERTY_NATIVE_TARGETS, manifest.nativeTargets.isNotEmpty()) {
manifest.nativeTargets.sorted().joinToString(" ")
}
@@ -179,6 +179,7 @@ fun MockNativeManifestDataProvider(
isInterop: Boolean = true,
packageFqName: String? = "mock",
exportForwardDeclarations: List<String> = emptyList(),
includedForwardDeclarations: List<String> = emptyList(),
nativeTargets: Collection<String> = emptyList(),
shortName: String? = "mock"
): NativeManifestDataProvider = object : NativeManifestDataProvider {
@@ -190,6 +191,7 @@ fun MockNativeManifestDataProvider(
isInterop = isInterop,
packageFqName = packageFqName,
exportForwardDeclarations = exportForwardDeclarations,
includedForwardDeclarations = includedForwardDeclarations,
nativeTargets = nativeTargets,
shortName = shortName,
commonizerTarget = target,