[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
This commit is contained in:
Pavel Punegov
2023-05-25 14:59:13 +02:00
committed by Space Team
parent 347c748182
commit 47c7dfe6b4
2 changed files with 7 additions and 2 deletions
@@ -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<String>.toSpaceSeparatedString(): String = joinToString(separator = " ") {
if (it.contains(" ")) "\"$it\"" else it
}
@@ -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!! }