[KLIB] Add short_name to klib manifest

Fixes for KT-36720 and KT-36721 change a scheme that is used to generate
unique names for klibs: now we use "fully qualified" names that
include a group and a name of a library (e.g. org.jetbrains.kotlin.
native.posix).

But in some cases we still need short library names for Kotlin/Native.
For example to display platform libs in the IDE or to export some
symbols of a library to an ObjC framework.

This patch introduces a corresponding property to klib manifest.
This commit is contained in:
Ilya Matveev
2020-03-24 17:02:24 +07:00
parent 6e1af0caee
commit 343e8c6f84
2 changed files with 9 additions and 1 deletions
@@ -16,6 +16,7 @@ const val KLIB_PROPERTY_PACKAGE = "package"
const val KLIB_PROPERTY_INTEROP = "interop"
const val KLIB_PROPERTY_EXPORT_FORWARD_DECLARATIONS = "exportForwardDeclarations"
const val KLIB_PROPERTY_BUILTINS_PLATFORM = "builtins_platform"
const val KLIB_PROPERTY_SHORT_NAME = "short_name"
/**
* Abstractions for getting access to the information stored inside of Kotlin/Native library.
@@ -52,6 +53,9 @@ interface IrLibrary {
val BaseKotlinLibrary.uniqueName: String
get() = manifestProperties.getProperty(KLIB_PROPERTY_UNIQUE_NAME)!!
val BaseKotlinLibrary.shortName: String?
get() = manifestProperties.getProperty(KLIB_PROPERTY_SHORT_NAME)
val BaseKotlinLibrary.unresolvedDependencies: List<UnresolvedLibrary>
get() = manifestProperties.propertyList(KLIB_PROPERTY_DEPENDS, escapeInQuotes = true)
.map { UnresolvedLibrary(it, manifestProperties.getProperty("dependency_version_$it")) }
@@ -23,7 +23,8 @@ open class BaseWriterImpl(
moduleName: String,
override val versions: KotlinLibraryVersioning,
builtInsPlatform: BuiltInsPlatform,
val nopack: Boolean = false
val nopack: Boolean = false,
val shortName: String? = null
) : BaseWriter {
val klibFile = File("${libraryLayout.libDir.path}.$KLIB_FILE_EXTENSION")
@@ -40,6 +41,9 @@ open class BaseWriterImpl(
manifestProperties.writeKonanLibraryVersioning(versions)
if (builtInsPlatform != BuiltInsPlatform.COMMON)
manifestProperties.setProperty(KLIB_PROPERTY_BUILTINS_PLATFORM, builtInsPlatform.name)
shortName?.let {
manifestProperties.setProperty(KLIB_PROPERTY_SHORT_NAME, it)
}
}
override fun addLinkDependencies(libraries: List<KotlinLibrary>) {