From 47c7dfe6b413fae075f0ad6b11c2d59a03da825e Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Thu, 25 May 2023 14:59:13 +0200 Subject: [PATCH] [K/N][klib] Wrap library dependencies with quotation marks Fixes ^KT-58537. Space in the library now should be correctly parsed now Klib readers can already read this --- .../kotlin/library/impl/KotlinLibraryWriterImpl.kt | 6 +++++- .../kotlin/commonizer/konan/NativeSensitiveManifestData.kt | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryWriterImpl.kt b/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryWriterImpl.kt index 288d5ae353f..8f3c32dea38 100644 --- a/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryWriterImpl.kt +++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryWriterImpl.kt @@ -62,7 +62,7 @@ class BaseWriterImpl( // make sure there are no leftovers from the .def file. return } else { - val newValue = libraries.joinToString(" ") { it.uniqueName } + val newValue = libraries.map { it.uniqueName }.toSpaceSeparatedString() manifestProperties.setProperty(KLIB_PROPERTY_DEPENDS, newValue) libraries.forEach { it -> if (it.versions.libraryVersion != null) { @@ -182,4 +182,8 @@ enum class BuiltInsPlatform { companion object { fun parseFromString(name: String): BuiltInsPlatform? = values().firstOrNull { it.name == name } } +} + +fun List.toSpaceSeparatedString(): String = joinToString(separator = " ") { + if (it.contains(" ")) "\"$it\"" else it } \ No newline at end of file diff --git a/native/commonizer/src/org/jetbrains/kotlin/commonizer/konan/NativeSensitiveManifestData.kt b/native/commonizer/src/org/jetbrains/kotlin/commonizer/konan/NativeSensitiveManifestData.kt index d4a7ff2f455..eb98c08b657 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/commonizer/konan/NativeSensitiveManifestData.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/commonizer/konan/NativeSensitiveManifestData.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.commonizer.* import org.jetbrains.kotlin.konan.properties.propertyList import org.jetbrains.kotlin.library.* import org.jetbrains.kotlin.library.impl.BaseWriterImpl +import org.jetbrains.kotlin.library.impl.toSpaceSeparatedString /** * The set of properties in manifest of Kotlin/Native library that should be @@ -53,7 +54,7 @@ fun BaseWriterImpl.addManifest(manifest: NativeSensitiveManifestData) { // Make sure all the lists are sorted for reproducible output addOptionalProperty(KLIB_PROPERTY_DEPENDS, manifest.dependencies.isNotEmpty()) { - manifest.dependencies.sorted().joinToString(separator = " ") + manifest.dependencies.sorted().toSpaceSeparatedString() } addOptionalProperty(KLIB_PROPERTY_INTEROP, manifest.isInterop) { "true" } addOptionalProperty(KLIB_PROPERTY_PACKAGE, manifest.packageFqName != null) { manifest.packageFqName!! }