[KLIB] Introduce isJsStdlib() and isWasmStdlib() checks for KLIBs
This commit is contained in:
committed by
Space Team
parent
4892a81178
commit
d65fc00578
@@ -3,6 +3,7 @@ package org.jetbrains.kotlin.library
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.konan.properties.Properties
|
||||
import org.jetbrains.kotlin.konan.properties.propertyList
|
||||
import org.jetbrains.kotlin.library.impl.BuiltInsPlatform
|
||||
|
||||
/**
|
||||
* [org.jetbrains.kotlin.library.KotlinAbiVersion]
|
||||
@@ -93,15 +94,21 @@ interface IrLibrary {
|
||||
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
|
||||
get() = manifestProperties.getProperty(KLIB_PROPERTY_UNIQUE_NAME)!!
|
||||
|
||||
val BaseKotlinLibrary.shortName: String?
|
||||
get() = manifestProperties.getProperty(KLIB_PROPERTY_SHORT_NAME)
|
||||
|
||||
val BaseKotlinLibrary.isNativeStdlib: Boolean
|
||||
get() = uniqueName == KOTLIN_STDLIB_NAME
|
||||
|
||||
val BaseKotlinLibrary.unresolvedDependencies: List<RequiredUnresolvedLibrary>
|
||||
get() = unresolvedDependencies(lenient = false).map { it as RequiredUnresolvedLibrary }
|
||||
|
||||
@@ -139,8 +146,12 @@ val KotlinLibrary.containsErrorCode: Boolean
|
||||
val KotlinLibrary.commonizerTarget: String?
|
||||
get() = manifestProperties.getProperty(KLIB_PROPERTY_COMMONIZER_TARGET)
|
||||
|
||||
@Deprecated("Use BaseKotlinLibrary.builtInsPlatform instead", level = DeprecationLevel.HIDDEN)
|
||||
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>?
|
||||
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.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 {
|
||||
val searchRoots: List<File>
|
||||
@@ -187,7 +192,7 @@ abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
|
||||
.asSequence()
|
||||
.filter { it.name.startsWith(prefix) }
|
||||
.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 { resolve(it, isDefaultLink = true) }
|
||||
} else emptySequence()
|
||||
@@ -197,7 +202,7 @@ abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
|
||||
val result = mutableListOf<L>()
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user