A couple of fixes for js library resolver
This commit is contained in:
committed by
alexander-gorshenev
parent
e5dbec4523
commit
47fba2ee4b
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.library.impl.buildKoltinLibrary
|
||||
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
||||
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
|
||||
import org.jetbrains.kotlin.library.resolver.TopologicalLibraryOrder
|
||||
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -80,6 +81,31 @@ 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>): 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
|
||||
// TODO: pass logger attached to message collector here.
|
||||
).libraryResolver()
|
||||
val resolvedLibraries =
|
||||
libraryResolver.resolveWithDependencies(
|
||||
unresolvedLibraries = unresolvedLibraries,
|
||||
noStdLib = true,
|
||||
noDefaultLibs = true,
|
||||
noEndorsedLibs = true
|
||||
)
|
||||
return resolvedLibraries
|
||||
}
|
||||
|
||||
|
||||
fun generateKLib(
|
||||
project: Project,
|
||||
files: List<KtFile>,
|
||||
|
||||
@@ -116,19 +116,7 @@ fun main(args: Array<String>) {
|
||||
if (outputPath == null) {
|
||||
error("Please set path to .klm file: `-o some/dir/module-name.klm`")
|
||||
}
|
||||
|
||||
val dependencyAbsolutePaths = dependencies.map{ File(it).absolutePath }
|
||||
val unresolvedLibraries = dependencies.map { UnresolvedLibrary(it, null) }
|
||||
// Configure the resolver to only understand absolute path libraries.
|
||||
val libraryResolver = KotlinLibrarySearchPathResolver<KotlinLibrary>(
|
||||
repositories = emptyList(),
|
||||
directLibs = dependencyAbsolutePaths,
|
||||
distributionKlib = null,
|
||||
localKotlinDir = null,
|
||||
skipCurrentDir = true
|
||||
// TODO: pass logger attached to message collector here.
|
||||
).libraryResolver()
|
||||
val resolvedLibraries = libraryResolver.resolveWithDependencies(unresolvedLibraries, true, true, true)
|
||||
val resolvedLibraries = jsResolveLibraries(dependencies)
|
||||
|
||||
buildKLib(File(outputPath).absolutePath, listOfKtFilesFrom(inputFiles), outputPath, resolvedLibraries, listOfKtFilesFrom(commonSources))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user