Initial implementation of klib components

This commit is contained in:
Alexander Gorshenev
2020-01-14 15:58:48 +03:00
committed by alexander-gorshenev
parent f949b48b4a
commit ccf084b1a5
10 changed files with 92 additions and 29 deletions
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.KotlinLibraryProperResolverWithAttributes
import org.jetbrains.kotlin.library.UnresolvedLibrary
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
import org.jetbrains.kotlin.library.impl.createKotlinLibraryComponents
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
import org.jetbrains.kotlin.util.Logger
@@ -37,7 +38,7 @@ class JsLibraryResolver(
emptyList()
) {
// Stick with the default KotlinLibrary for now.
override fun libraryBuilder(file: File, isDefault: Boolean) = createKotlinLibrary(file, isDefault)
override fun libraryComponentBuilder(file: File, isDefault: Boolean) = createKotlinLibraryComponents(file, isDefault)
}
// TODO: This is a temporary set of library resolver policies for js compiler.
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.konan.util.KlibMetadataFactories
import org.jetbrains.kotlin.library.*
import org.jetbrains.kotlin.library.impl.buildKoltinLibrary
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
import org.jetbrains.kotlin.library.impl.createKotlinLibraryComponents
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
import org.jetbrains.kotlin.library.resolver.TopologicalLibraryOrder
import org.jetbrains.kotlin.metadata.ProtoBuf
@@ -73,8 +74,11 @@ val KotlinLibrary.isBuiltIns: Boolean
.propertyList(KLIB_PROPERTY_DEPENDS, escapeInQuotes = true)
.isEmpty()
// TODO: The only place loadKlib() is used now is Wasm backend.
// Need to move it to SearchPathResolver too.
// Otherwise there's no good way to choose between the components.
fun loadKlib(klibPath: String) =
createKotlinLibrary(KFile(KFile(klibPath).absolutePath))
createKotlinLibraryComponents(KFile(KFile(klibPath).absolutePath)).single()
val emptyLoggingContext = object : LoggingContext {
override var inVerbosePhase = false