JS search path resolver with attributes.
Warn on inclusion of klibs with the same name in manifest
This commit is contained in:
committed by
alexander-gorshenev
parent
bc4be53569
commit
55805ddeb8
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js
|
||||
|
||||
import org.jetbrains.kotlin.konan.KonanVersion
|
||||
import org.jetbrains.kotlin.library.KotlinAbiVersion
|
||||
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.resolver.KotlinLibraryResolveResult
|
||||
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
|
||||
import org.jetbrains.kotlin.util.Logger
|
||||
import java.io.File
|
||||
|
||||
class JsLibraryResolver(
|
||||
repositories: List<String>,
|
||||
directLibs: List<String>,
|
||||
knownAbiVersions: List<KotlinAbiVersion>?,
|
||||
knownCompilerVersions: List<KonanVersion>?,
|
||||
distributionKlib: String?,
|
||||
localKotlinDir: String?,
|
||||
skipCurrentDir: Boolean,
|
||||
logger: Logger
|
||||
) : KotlinLibraryProperResolverWithAttributes<KotlinLibrary>(
|
||||
repositories,
|
||||
directLibs,
|
||||
knownAbiVersions,
|
||||
knownCompilerVersions,
|
||||
distributionKlib,
|
||||
localKotlinDir,
|
||||
skipCurrentDir,
|
||||
logger,
|
||||
::createKotlinLibrary
|
||||
)
|
||||
|
||||
// TODO: This is a temporary set of library resolver policies for js compiler.
|
||||
fun jsResolveLibraries(libraries: List<String>, logger: Logger): KotlinLibraryResolveResult {
|
||||
val unresolvedLibraries = libraries.map { UnresolvedLibrary(it, null) }
|
||||
val libraryAbsolutePaths = libraries.map { File(it).absolutePath }
|
||||
// Configure the resolver to only work with absolute paths for now.
|
||||
val libraryResolver = JsLibraryResolver(
|
||||
repositories = emptyList(),
|
||||
directLibs = libraryAbsolutePaths,
|
||||
knownAbiVersions = listOf(KotlinAbiVersion.CURRENT),
|
||||
knownCompilerVersions = emptyList<KonanVersion>(),
|
||||
distributionKlib = null,
|
||||
localKotlinDir = null,
|
||||
skipCurrentDir = false,
|
||||
logger = logger
|
||||
).libraryResolver()
|
||||
val resolvedLibraries =
|
||||
libraryResolver.resolveWithDependencies(
|
||||
unresolvedLibraries = unresolvedLibraries,
|
||||
noStdLib = true,
|
||||
noDefaultLibs = true,
|
||||
noEndorsedLibs = true
|
||||
)
|
||||
return resolvedLibraries
|
||||
}
|
||||
@@ -80,29 +80,6 @@ private val CompilerConfiguration.metadataVersion
|
||||
|
||||
class KotlinFileSerializedData(val metadata: ByteArray, val irData: SerializedIrFile)
|
||||
|
||||
// TODO: This is a temporary set of library resolver policies for js compiler.
|
||||
fun jsResolveLibraries(libraries: List<String>, logger: Logger): KotlinLibraryResolveResult {
|
||||
val unresolvedLibraries = libraries.map { UnresolvedLibrary(it ,null) }
|
||||
val libraryAbsolutePaths = libraries.map{ File(it).absolutePath }
|
||||
// Configure the resolver to only work with absolute paths for now.
|
||||
val libraryResolver = KotlinLibrarySearchPathResolver<KotlinLibrary>(
|
||||
repositories = emptyList(),
|
||||
directLibs = libraryAbsolutePaths,
|
||||
distributionKlib = null,
|
||||
localKotlinDir = null,
|
||||
skipCurrentDir = false,
|
||||
logger = logger
|
||||
).libraryResolver()
|
||||
val resolvedLibraries =
|
||||
libraryResolver.resolveWithDependencies(
|
||||
unresolvedLibraries = unresolvedLibraries,
|
||||
noStdLib = true,
|
||||
noDefaultLibs = true,
|
||||
noEndorsedLibs = true
|
||||
)
|
||||
return resolvedLibraries
|
||||
}
|
||||
|
||||
fun generateKLib(
|
||||
project: Project,
|
||||
files: List<KtFile>,
|
||||
|
||||
Reference in New Issue
Block a user