[KLIB] Introduce isJsStdlib() and isWasmStdlib() checks for KLIBs
This commit is contained in:
committed by
Space Team
parent
4892a81178
commit
d65fc00578
+2
-2
@@ -74,7 +74,7 @@ internal class LibraryAbiReaderImpl(libraryFile: File, filters: List<AbiReadingF
|
|||||||
private fun readManifest(): LibraryManifest {
|
private fun readManifest(): LibraryManifest {
|
||||||
val versions = library.versions
|
val versions = library.versions
|
||||||
return LibraryManifest(
|
return LibraryManifest(
|
||||||
platform = library.builtInsPlatform,
|
platform = library.builtInsPlatform?.name,
|
||||||
nativeTargets = library.nativeTargets.sorted(),
|
nativeTargets = library.nativeTargets.sorted(),
|
||||||
compilerVersion = versions.compilerVersion,
|
compilerVersion = versions.compilerVersion,
|
||||||
abiVersion = versions.abiVersion?.toString(),
|
abiVersion = versions.abiVersion?.toString(),
|
||||||
@@ -94,7 +94,7 @@ private class LibraryDeserializer(
|
|||||||
supportedSignatureVersions: Set<AbiSignatureVersion>,
|
supportedSignatureVersions: Set<AbiSignatureVersion>,
|
||||||
private val compositeFilter: AbiReadingFilter.Composite?
|
private val compositeFilter: AbiReadingFilter.Composite?
|
||||||
) {
|
) {
|
||||||
private val platform: BuiltInsPlatform? = library.builtInsPlatform?.let(BuiltInsPlatform::parseFromString)
|
private val platform: BuiltInsPlatform? = library.builtInsPlatform
|
||||||
|
|
||||||
private val interner = IrInterningService()
|
private val interner = IrInterningService()
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -15,8 +15,10 @@ import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||||
|
import org.jetbrains.kotlin.library.isJsStdlib
|
||||||
import org.jetbrains.kotlin.library.metadata.*
|
import org.jetbrains.kotlin.library.metadata.*
|
||||||
import org.jetbrains.kotlin.library.isNativeStdlib
|
import org.jetbrains.kotlin.library.isNativeStdlib
|
||||||
|
import org.jetbrains.kotlin.library.isWasmStdlib
|
||||||
import org.jetbrains.kotlin.name.*
|
import org.jetbrains.kotlin.name.*
|
||||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||||
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration
|
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration
|
||||||
@@ -57,7 +59,7 @@ class KlibMetadataModuleDescriptorFactoryImpl(
|
|||||||
storageManager,
|
storageManager,
|
||||||
moduleDescriptor,
|
moduleDescriptor,
|
||||||
configuration = CompilerDeserializationConfiguration(languageVersionSettings),
|
configuration = CompilerDeserializationConfiguration(languageVersionSettings),
|
||||||
compositePackageFragmentAddend = runIf(library.isNativeStdlib) {
|
compositePackageFragmentAddend = runIf(library.isNativeStdlib || library.isJsStdlib || library.isWasmStdlib) {
|
||||||
functionInterfacePackageFragmentProvider(storageManager, moduleDescriptor)
|
functionInterfacePackageFragmentProvider(storageManager, moduleDescriptor)
|
||||||
},
|
},
|
||||||
lookupTracker = lookupTracker
|
lookupTracker = lookupTracker
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.jetbrains.kotlin.library
|
|||||||
import org.jetbrains.kotlin.konan.file.File
|
import org.jetbrains.kotlin.konan.file.File
|
||||||
import org.jetbrains.kotlin.konan.properties.Properties
|
import org.jetbrains.kotlin.konan.properties.Properties
|
||||||
import org.jetbrains.kotlin.konan.properties.propertyList
|
import org.jetbrains.kotlin.konan.properties.propertyList
|
||||||
|
import org.jetbrains.kotlin.library.impl.BuiltInsPlatform
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [org.jetbrains.kotlin.library.KotlinAbiVersion]
|
* [org.jetbrains.kotlin.library.KotlinAbiVersion]
|
||||||
@@ -93,15 +94,21 @@ interface IrLibrary {
|
|||||||
fun bodies(fileIndex: Int): ByteArray
|
fun bodies(fileIndex: Int): ByteArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val BaseKotlinLibrary.isNativeStdlib: Boolean
|
||||||
|
get() = uniqueName == KOTLIN_NATIVE_STDLIB_NAME && builtInsPlatform == BuiltInsPlatform.NATIVE
|
||||||
|
|
||||||
|
val BaseKotlinLibrary.isJsStdlib: Boolean
|
||||||
|
get() = uniqueName == KOTLIN_JS_STDLIB_NAME && builtInsPlatform == BuiltInsPlatform.JS
|
||||||
|
|
||||||
|
val BaseKotlinLibrary.isWasmStdlib: Boolean
|
||||||
|
get() = uniqueName == KOTLIN_WASM_STDLIB_NAME && builtInsPlatform == BuiltInsPlatform.WASM
|
||||||
|
|
||||||
val BaseKotlinLibrary.uniqueName: String
|
val BaseKotlinLibrary.uniqueName: String
|
||||||
get() = manifestProperties.getProperty(KLIB_PROPERTY_UNIQUE_NAME)!!
|
get() = manifestProperties.getProperty(KLIB_PROPERTY_UNIQUE_NAME)!!
|
||||||
|
|
||||||
val BaseKotlinLibrary.shortName: String?
|
val BaseKotlinLibrary.shortName: String?
|
||||||
get() = manifestProperties.getProperty(KLIB_PROPERTY_SHORT_NAME)
|
get() = manifestProperties.getProperty(KLIB_PROPERTY_SHORT_NAME)
|
||||||
|
|
||||||
val BaseKotlinLibrary.isNativeStdlib: Boolean
|
|
||||||
get() = uniqueName == KOTLIN_STDLIB_NAME
|
|
||||||
|
|
||||||
val BaseKotlinLibrary.unresolvedDependencies: List<RequiredUnresolvedLibrary>
|
val BaseKotlinLibrary.unresolvedDependencies: List<RequiredUnresolvedLibrary>
|
||||||
get() = unresolvedDependencies(lenient = false).map { it as RequiredUnresolvedLibrary }
|
get() = unresolvedDependencies(lenient = false).map { it as RequiredUnresolvedLibrary }
|
||||||
|
|
||||||
@@ -139,8 +146,12 @@ val KotlinLibrary.containsErrorCode: Boolean
|
|||||||
val KotlinLibrary.commonizerTarget: String?
|
val KotlinLibrary.commonizerTarget: String?
|
||||||
get() = manifestProperties.getProperty(KLIB_PROPERTY_COMMONIZER_TARGET)
|
get() = manifestProperties.getProperty(KLIB_PROPERTY_COMMONIZER_TARGET)
|
||||||
|
|
||||||
|
@Deprecated("Use BaseKotlinLibrary.builtInsPlatform instead", level = DeprecationLevel.HIDDEN)
|
||||||
val KotlinLibrary.builtInsPlatform: String?
|
val KotlinLibrary.builtInsPlatform: String?
|
||||||
get() = manifestProperties.getProperty(KLIB_PROPERTY_BUILTINS_PLATFORM)
|
get() = builtInsPlatform?.name
|
||||||
|
|
||||||
|
val BaseKotlinLibrary.builtInsPlatform: BuiltInsPlatform?
|
||||||
|
get() = manifestProperties.getProperty(KLIB_PROPERTY_BUILTINS_PLATFORM)?.let(BuiltInsPlatform::parseFromString)
|
||||||
|
|
||||||
val BaseKotlinLibrary.commonizerNativeTargets: List<String>?
|
val BaseKotlinLibrary.commonizerNativeTargets: List<String>?
|
||||||
get() = if (manifestProperties.containsKey(KLIB_PROPERTY_COMMONIZER_NATIVE_TARGETS))
|
get() = if (manifestProperties.containsKey(KLIB_PROPERTY_COMMONIZER_NATIVE_TARGETS))
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ import org.jetbrains.kotlin.util.suffixIfNot
|
|||||||
import java.nio.file.InvalidPathException
|
import java.nio.file.InvalidPathException
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
const val KOTLIN_STDLIB_NAME = "stdlib"
|
@Deprecated("Use KOTLIN_NATIVE_STDLIB_NAME, KOTLIN_JS_STDLIB_NAME or KOTLIN_WASM_STDLIB_NAME instead", level = DeprecationLevel.HIDDEN)
|
||||||
|
const val KOTLIN_STDLIB_NAME: String = "stdlib"
|
||||||
|
|
||||||
|
const val KOTLIN_NATIVE_STDLIB_NAME: String = "stdlib"
|
||||||
|
const val KOTLIN_JS_STDLIB_NAME: String = "kotlin"
|
||||||
|
const val KOTLIN_WASM_STDLIB_NAME: String = "kotlin"
|
||||||
|
|
||||||
interface SearchPathResolver<L : KotlinLibrary> : WithLogger {
|
interface SearchPathResolver<L : KotlinLibrary> : WithLogger {
|
||||||
val searchRoots: List<File>
|
val searchRoots: List<File>
|
||||||
@@ -187,7 +192,7 @@ abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
|
|||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it.name.startsWith(prefix) }
|
.filter { it.name.startsWith(prefix) }
|
||||||
.filterNot { it.name.startsWith('.') }
|
.filterNot { it.name.startsWith('.') }
|
||||||
.filterNot { it.name.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT) == KOTLIN_STDLIB_NAME }
|
.filterNot { it.name.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT) == KOTLIN_NATIVE_STDLIB_NAME }
|
||||||
.map { UnresolvedLibrary(it.absolutePath, null) }
|
.map { UnresolvedLibrary(it.absolutePath, null) }
|
||||||
.map { resolve(it, isDefaultLink = true) }
|
.map { resolve(it, isDefaultLink = true) }
|
||||||
} else emptySequence()
|
} else emptySequence()
|
||||||
@@ -197,7 +202,7 @@ abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
|
|||||||
val result = mutableListOf<L>()
|
val result = mutableListOf<L>()
|
||||||
|
|
||||||
if (!noStdLib) {
|
if (!noStdLib) {
|
||||||
result.add(resolve(UnresolvedLibrary(KOTLIN_STDLIB_NAME, null), true))
|
result.add(resolve(UnresolvedLibrary(KOTLIN_NATIVE_STDLIB_NAME, null), true))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Endorsed libraries in distHead.
|
// Endorsed libraries in distHead.
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ internal fun IdeaKotlinBinaryAttributes(attributes: AttributeContainer): IdeaKot
|
|||||||
|
|
||||||
internal fun KlibExtra(library: KotlinLibrary): KlibExtra {
|
internal fun KlibExtra(library: KotlinLibrary): KlibExtra {
|
||||||
return KlibExtra(
|
return KlibExtra(
|
||||||
builtInsPlatform = library.builtInsPlatform,
|
builtInsPlatform = library.builtInsPlatform?.name,
|
||||||
uniqueName = library.uniqueName,
|
uniqueName = library.uniqueName,
|
||||||
shortName = library.shortName,
|
shortName = library.shortName,
|
||||||
packageFqName = library.packageFqName,
|
packageFqName = library.packageFqName,
|
||||||
|
|||||||
Reference in New Issue
Block a user