committed by
alexander-gorshenev
parent
e327b174a2
commit
dfa509ec5b
@@ -25,9 +25,12 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.konan.DeserializedKlibModuleOrigin
|
import org.jetbrains.kotlin.descriptors.konan.DeserializedKlibModuleOrigin
|
||||||
import org.jetbrains.kotlin.konan.util.KlibMetadataFactories
|
import org.jetbrains.kotlin.konan.util.KlibMetadataFactories
|
||||||
import org.jetbrains.kotlin.library.*
|
import org.jetbrains.kotlin.library.KotlinAbiVersion
|
||||||
|
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||||
|
import org.jetbrains.kotlin.library.KotlinLibraryVersioning
|
||||||
|
import org.jetbrains.kotlin.library.SerializedMetadata
|
||||||
import org.jetbrains.kotlin.library.impl.buildKoltinLibrary
|
import org.jetbrains.kotlin.library.impl.buildKoltinLibrary
|
||||||
import org.jetbrains.kotlin.library.impl.createKotlinLibraryComponents
|
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.metadata.parseModuleHeader
|
import org.jetbrains.kotlin.library.metadata.parseModuleHeader
|
||||||
import org.jetbrains.kotlin.metadata.builtins.BuiltInsBinaryVersion
|
import org.jetbrains.kotlin.metadata.builtins.BuiltInsBinaryVersion
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -107,8 +110,7 @@ private class KlibMetadataDependencyContainer(
|
|||||||
val klibFiles = classpathFiles
|
val klibFiles = classpathFiles
|
||||||
.filter { it.extension == "klib" || it.isDirectory }
|
.filter { it.extension == "klib" || it.isDirectory }
|
||||||
|
|
||||||
// TODO: need to move K2Metadata to SearchPathResolver.
|
klibFiles.map { createKotlinLibrary(org.jetbrains.kotlin.konan.file.File(it.absolutePath)) }
|
||||||
klibFiles.map { resolveSingleFileKlib(org.jetbrains.kotlin.konan.file.File(it.absolutePath)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val builtIns
|
private val builtIns
|
||||||
|
|||||||
+1
-2
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.library.KotlinLibrary
|
|||||||
import org.jetbrains.kotlin.library.KotlinLibraryProperResolverWithAttributes
|
import org.jetbrains.kotlin.library.KotlinLibraryProperResolverWithAttributes
|
||||||
import org.jetbrains.kotlin.library.UnresolvedLibrary
|
import org.jetbrains.kotlin.library.UnresolvedLibrary
|
||||||
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
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.KotlinLibraryResolveResult
|
||||||
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
|
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
|
||||||
import org.jetbrains.kotlin.util.Logger
|
import org.jetbrains.kotlin.util.Logger
|
||||||
@@ -38,7 +37,7 @@ class JsLibraryResolver(
|
|||||||
emptyList()
|
emptyList()
|
||||||
) {
|
) {
|
||||||
// Stick with the default KotlinLibrary for now.
|
// Stick with the default KotlinLibrary for now.
|
||||||
override fun libraryComponentBuilder(file: File, isDefault: Boolean) = createKotlinLibraryComponents(file, isDefault)
|
override fun libraryBuilder(file: File, isDefault: Boolean) = createKotlinLibrary(file, isDefault)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This is a temporary set of library resolver policies for js compiler.
|
// TODO: This is a temporary set of library resolver policies for js compiler.
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.konan.util.KlibMetadataFactories
|
|||||||
import org.jetbrains.kotlin.library.*
|
import org.jetbrains.kotlin.library.*
|
||||||
import org.jetbrains.kotlin.library.impl.buildKoltinLibrary
|
import org.jetbrains.kotlin.library.impl.buildKoltinLibrary
|
||||||
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
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.KotlinLibraryResolveResult
|
||||||
import org.jetbrains.kotlin.library.resolver.TopologicalLibraryOrder
|
import org.jetbrains.kotlin.library.resolver.TopologicalLibraryOrder
|
||||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||||
@@ -74,10 +73,8 @@ val KotlinLibrary.isBuiltIns: Boolean
|
|||||||
.propertyList(KLIB_PROPERTY_DEPENDS, escapeInQuotes = true)
|
.propertyList(KLIB_PROPERTY_DEPENDS, escapeInQuotes = true)
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
|
|
||||||
// TODO: The only place loadKlib() is used now is Wasm backend.
|
|
||||||
// Need to move it to SearchPathResolver too.
|
|
||||||
fun loadKlib(klibPath: String) =
|
fun loadKlib(klibPath: String) =
|
||||||
resolveSingleFileKlib(KFile(KFile(klibPath).absolutePath))
|
createKotlinLibrary(KFile(KFile(klibPath).absolutePath))
|
||||||
|
|
||||||
val emptyLoggingContext = object : LoggingContext {
|
val emptyLoggingContext = object : LoggingContext {
|
||||||
override var inVerbosePhase = false
|
override var inVerbosePhase = false
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ const val KLIB_PROPERTY_EXPORT_FORWARD_DECLARATIONS = "exportForwardDeclarations
|
|||||||
interface BaseKotlinLibrary {
|
interface BaseKotlinLibrary {
|
||||||
val libraryName: String
|
val libraryName: String
|
||||||
val libraryFile: File
|
val libraryFile: File
|
||||||
val componentList: List<String>
|
|
||||||
val versions: KotlinLibraryVersioning
|
val versions: KotlinLibraryVersioning
|
||||||
// Whether this library is default (provided by distribution)?
|
// Whether this library is default (provided by distribution)?
|
||||||
val isDefault: Boolean
|
val isDefault: Boolean
|
||||||
val manifestProperties: Properties
|
val manifestProperties: Properties
|
||||||
val has_pre_1_4_manifest: Boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MetadataLibrary {
|
interface MetadataLibrary {
|
||||||
|
|||||||
@@ -30,20 +30,15 @@ interface KotlinLibraryLayout {
|
|||||||
val libDir: File
|
val libDir: File
|
||||||
val libraryName: String
|
val libraryName: String
|
||||||
get() = libDir.path
|
get() = libDir.path
|
||||||
val component: String?
|
|
||||||
val componentDir: File
|
|
||||||
get() = File(libDir, component!!)
|
|
||||||
val manifestFile
|
val manifestFile
|
||||||
get() = File(componentDir, KLIB_MANIFEST_FILE_NAME)
|
|
||||||
val resourcesDir
|
|
||||||
get() = File(componentDir, "resources")
|
|
||||||
val pre_1_4_manifest: File
|
|
||||||
get() = File(libDir, KLIB_MANIFEST_FILE_NAME)
|
get() = File(libDir, KLIB_MANIFEST_FILE_NAME)
|
||||||
|
val resourcesDir
|
||||||
|
get() = File(libDir, "resources")
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MetadataKotlinLibraryLayout : KotlinLibraryLayout {
|
interface MetadataKotlinLibraryLayout : KotlinLibraryLayout {
|
||||||
val metadataDir
|
val metadataDir
|
||||||
get() = File(componentDir, "linkdata")
|
get() = File(libDir, "linkdata")
|
||||||
val moduleHeaderFile
|
val moduleHeaderFile
|
||||||
get() = File(metadataDir, KLIB_MODULE_METADATA_FILE_NAME)
|
get() = File(metadataDir, KLIB_MODULE_METADATA_FILE_NAME)
|
||||||
|
|
||||||
@@ -56,7 +51,7 @@ interface MetadataKotlinLibraryLayout : KotlinLibraryLayout {
|
|||||||
|
|
||||||
interface IrKotlinLibraryLayout : KotlinLibraryLayout {
|
interface IrKotlinLibraryLayout : KotlinLibraryLayout {
|
||||||
val irDir
|
val irDir
|
||||||
get() = File(componentDir, KLIB_IR_FOLDER_NAME)
|
get() = File(libDir, KLIB_IR_FOLDER_NAME)
|
||||||
val irDeclarations
|
val irDeclarations
|
||||||
get() = File(irDir, "irDeclarations.knd")
|
get() = File(irDir, "irDeclarations.knd")
|
||||||
val irSymbols
|
val irSymbols
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.jetbrains.kotlin.library
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.konan.CompilerVersion
|
import org.jetbrains.kotlin.konan.CompilerVersion
|
||||||
import org.jetbrains.kotlin.konan.file.File
|
import org.jetbrains.kotlin.konan.file.File
|
||||||
import org.jetbrains.kotlin.library.impl.createKotlinLibraryComponents
|
|
||||||
import org.jetbrains.kotlin.library.impl.isPre_1_4_Library
|
|
||||||
import org.jetbrains.kotlin.util.*
|
import org.jetbrains.kotlin.util.*
|
||||||
|
|
||||||
const val KOTLIN_STDLIB_NAME = "stdlib"
|
const val KOTLIN_STDLIB_NAME = "stdlib"
|
||||||
@@ -23,7 +21,7 @@ interface SearchPathResolverWithAttributes<L: KotlinLibrary>: SearchPathResolver
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This is a simple library resolver that only cares for file names.
|
// This is a simple library resolver that only cares for file names.
|
||||||
abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary> (
|
abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary>(
|
||||||
repositories: List<String>,
|
repositories: List<String>,
|
||||||
directLibs: List<String>,
|
directLibs: List<String>,
|
||||||
val distributionKlib: String?,
|
val distributionKlib: String?,
|
||||||
@@ -45,10 +43,10 @@ abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary> (
|
|||||||
|
|
||||||
private val repoRoots: List<File> by lazy { repositories.map { File(it) } }
|
private val repoRoots: List<File> by lazy { repositories.map { File(it) } }
|
||||||
|
|
||||||
abstract fun libraryComponentBuilder(file: File, isDefault: Boolean): List<L>
|
abstract fun libraryBuilder(file: File, isDefault: Boolean): L
|
||||||
|
|
||||||
private val directLibraries: List<KotlinLibrary> by lazy {
|
private val directLibraries: List<KotlinLibrary> by lazy {
|
||||||
directLibs.mapNotNull { found(File(it)) }.flatMap { libraryComponentBuilder(it, false) }
|
directLibs.mapNotNull { found(File(it)) }.map { libraryBuilder(it, false) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the place where we specify the order of library search.
|
// This is the place where we specify the order of library search.
|
||||||
@@ -57,7 +55,8 @@ abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary> (
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun found(candidate: File): File? {
|
private fun found(candidate: File): File? {
|
||||||
fun check(file: File): Boolean = file.exists
|
fun check(file: File): Boolean =
|
||||||
|
file.exists && (file.isFile || File(file, "manifest").exists)
|
||||||
|
|
||||||
val noSuffix = File(candidate.path.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT))
|
val noSuffix = File(candidate.path.removeSuffixIfPresent(KLIB_FILE_EXTENSION_WITH_DOT))
|
||||||
val withSuffix = File(candidate.path.suffixIfNot(KLIB_FILE_EXTENSION_WITH_DOT))
|
val withSuffix = File(candidate.path.suffixIfNot(KLIB_FILE_EXTENSION_WITH_DOT))
|
||||||
@@ -95,22 +94,11 @@ abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary> (
|
|||||||
return sequence.filterNotNull()
|
return sequence.filterNotNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Sequence<File>.filterOutPre_1_4_libraries(): Sequence<File> = this.filter{
|
|
||||||
if (it.isPre_1_4_Library) {
|
|
||||||
logger.warning("Skipping \"$it\" as it is a pre 1.4 library")
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean): L {
|
override fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean): L {
|
||||||
val givenPath = unresolved.path
|
val givenPath = unresolved.path
|
||||||
try {
|
try {
|
||||||
val fileSequence = resolutionSequence(givenPath)
|
val fileSequence = resolutionSequence(givenPath)
|
||||||
val matching = fileSequence
|
val matching = fileSequence.map { libraryBuilder(it, isDefaultLink) }
|
||||||
.filterOutPre_1_4_libraries()
|
|
||||||
.flatMap { libraryComponentBuilder(it, isDefaultLink).asSequence() }
|
|
||||||
.map { it.takeIf { libraryMatch(it, unresolved) } }
|
.map { it.takeIf { libraryMatch(it, unresolved) } }
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
|
|
||||||
@@ -225,26 +213,4 @@ abstract class KotlinLibraryProperResolverWithAttributes<L: KotlinLibrary>(
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class SingleKlibComponentResolver(
|
|
||||||
klibFile: String,
|
|
||||||
knownAbiVersions: List<KotlinAbiVersion>?,
|
|
||||||
logger: Logger
|
|
||||||
) : KotlinLibraryProperResolverWithAttributes<KotlinLibrary>(
|
|
||||||
emptyList(), listOf(klibFile), knownAbiVersions, emptyList(),
|
|
||||||
null, null, false, logger, emptyList()
|
|
||||||
) {
|
|
||||||
override fun libraryComponentBuilder(file: File, isDefault: Boolean) = createKotlinLibraryComponents(file, isDefault)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resolveSingleFileKlib(libraryFile: File,
|
|
||||||
logger: Logger = object : Logger {
|
|
||||||
override fun log(message: String) {}
|
|
||||||
override fun error(message: String) = kotlin.error("e: $message")
|
|
||||||
override fun warning(message: String) {}
|
|
||||||
override fun fatal(message: String) = kotlin.error("e: $message")
|
|
||||||
}
|
|
||||||
): KotlinLibrary {
|
|
||||||
return SingleKlibComponentResolver(libraryFile.absolutePath, listOf(KotlinAbiVersion.CURRENT), logger).resolve(libraryFile.absolutePath)
|
|
||||||
}
|
}
|
||||||
@@ -28,21 +28,8 @@ open class BaseKotlinLibraryImpl(
|
|||||||
override val libraryFile get() = access.klib
|
override val libraryFile get() = access.klib
|
||||||
override val libraryName: String by lazy { access.inPlace { it.libraryName } }
|
override val libraryName: String by lazy { access.inPlace { it.libraryName } }
|
||||||
|
|
||||||
override val componentList: List<String> by lazy {
|
|
||||||
access.inPlace {
|
|
||||||
it.libDir.listFiles
|
|
||||||
.filter { it.isDirectory }
|
|
||||||
.filter { it.listFiles.map { it.name }.contains(KLIB_MANIFEST_FILE_NAME) }
|
|
||||||
.map { it.name }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString() = "$libraryName[default=$isDefault]"
|
override fun toString() = "$libraryName[default=$isDefault]"
|
||||||
|
|
||||||
override val has_pre_1_4_manifest: Boolean by lazy {
|
|
||||||
access.inPlace { it.pre_1_4_manifest.exists }
|
|
||||||
}
|
|
||||||
|
|
||||||
override val manifestProperties: Properties by lazy {
|
override val manifestProperties: Properties by lazy {
|
||||||
access.inPlace { it.manifestFile.loadProperties() }
|
access.inPlace { it.manifestFile.loadProperties() }
|
||||||
}
|
}
|
||||||
@@ -234,12 +221,11 @@ open class KotlinLibraryImpl(
|
|||||||
|
|
||||||
fun createKotlinLibrary(
|
fun createKotlinLibrary(
|
||||||
libraryFile: File,
|
libraryFile: File,
|
||||||
component: String,
|
|
||||||
isDefault: Boolean = false
|
isDefault: Boolean = false
|
||||||
): KotlinLibrary {
|
): KotlinLibrary {
|
||||||
val baseAccess = BaseLibraryAccess<KotlinLibraryLayout>(libraryFile, component)
|
val baseAccess = BaseLibraryAccess<KotlinLibraryLayout>(libraryFile)
|
||||||
val metadataAccess = MetadataLibraryAccess<MetadataKotlinLibraryLayout>(libraryFile, component)
|
val metadataAccess = MetadataLibraryAccess<MetadataKotlinLibraryLayout>(libraryFile)
|
||||||
val irAccess = IrLibraryAccess<IrKotlinLibraryLayout>(libraryFile, component)
|
val irAccess = IrLibraryAccess<IrKotlinLibraryLayout>(libraryFile)
|
||||||
|
|
||||||
val base = BaseKotlinLibraryImpl(baseAccess, isDefault)
|
val base = BaseKotlinLibraryImpl(baseAccess, isDefault)
|
||||||
val metadata = MetadataLibraryImpl(metadataAccess)
|
val metadata = MetadataLibraryImpl(metadataAccess)
|
||||||
@@ -247,22 +233,4 @@ fun createKotlinLibrary(
|
|||||||
// val ir = IrPerFileLibraryImpl(irAccess)
|
// val ir = IrPerFileLibraryImpl(irAccess)
|
||||||
|
|
||||||
return KotlinLibraryImpl(base, metadata, ir)
|
return KotlinLibraryImpl(base, metadata, ir)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createKotlinLibraryComponents(
|
|
||||||
libraryFile: File,
|
|
||||||
isDefault: Boolean = true
|
|
||||||
) : List<KotlinLibrary> {
|
|
||||||
val baseAccess = BaseLibraryAccess<KotlinLibraryLayout>(libraryFile, null)
|
|
||||||
val base = BaseKotlinLibraryImpl(baseAccess, isDefault)
|
|
||||||
return base.componentList.map {
|
|
||||||
createKotlinLibrary(libraryFile, it, isDefault)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val File.isPre_1_4_Library: Boolean
|
|
||||||
get() {
|
|
||||||
val baseAccess = BaseLibraryAccess<KotlinLibraryLayout>(this, null)
|
|
||||||
val base = BaseKotlinLibraryImpl(baseAccess, false)
|
|
||||||
return base.has_pre_1_4_manifest
|
|
||||||
}
|
|
||||||
+9
-11
@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.library.*
|
|||||||
import org.jetbrains.kotlin.util.removeSuffixIfPresent
|
import org.jetbrains.kotlin.util.removeSuffixIfPresent
|
||||||
import java.nio.file.FileSystem
|
import java.nio.file.FileSystem
|
||||||
|
|
||||||
open class KotlinLibraryLayoutImpl(val klib: File, override val component: String?) : KotlinLibraryLayout {
|
open class KotlinLibraryLayoutImpl(val klib: File) : KotlinLibraryLayout {
|
||||||
val isZipped = klib.isFile
|
val isZipped = klib.isFile
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -32,7 +32,7 @@ open class KotlinLibraryLayoutImpl(val klib: File, override val component: Strin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MetadataLibraryLayoutImpl(klib: File, component: String) : KotlinLibraryLayoutImpl(klib, component), MetadataKotlinLibraryLayout {
|
class MetadataLibraryLayoutImpl(klib: File) : KotlinLibraryLayoutImpl(klib), MetadataKotlinLibraryLayout {
|
||||||
|
|
||||||
override val extractingToTemp: MetadataKotlinLibraryLayout by lazy {
|
override val extractingToTemp: MetadataKotlinLibraryLayout by lazy {
|
||||||
ExtractingMetadataLibraryImpl(this)
|
ExtractingMetadataLibraryImpl(this)
|
||||||
@@ -42,7 +42,7 @@ class MetadataLibraryLayoutImpl(klib: File, component: String) : KotlinLibraryLa
|
|||||||
FromZipMetadataLibraryImpl(this, zipFileSystem)
|
FromZipMetadataLibraryImpl(this, zipFileSystem)
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrLibraryLayoutImpl(klib: File, component: String) : KotlinLibraryLayoutImpl(klib, component), IrKotlinLibraryLayout {
|
class IrLibraryLayoutImpl(klib: File) : KotlinLibraryLayoutImpl(klib), IrKotlinLibraryLayout {
|
||||||
|
|
||||||
override val extractingToTemp: IrKotlinLibraryLayout by lazy {
|
override val extractingToTemp: IrKotlinLibraryLayout by lazy {
|
||||||
ExtractingIrLibraryImpl(this)
|
ExtractingIrLibraryImpl(this)
|
||||||
@@ -52,8 +52,8 @@ class IrLibraryLayoutImpl(klib: File, component: String) : KotlinLibraryLayoutIm
|
|||||||
FromZipIrLibraryImpl(this, zipFileSystem)
|
FromZipIrLibraryImpl(this, zipFileSystem)
|
||||||
}
|
}
|
||||||
|
|
||||||
open class BaseLibraryAccess<L : KotlinLibraryLayout>(val klib: File, component: String?) {
|
open class BaseLibraryAccess<L : KotlinLibraryLayout>(val klib: File) {
|
||||||
open val layout = KotlinLibraryLayoutImpl(klib, component)
|
open val layout = KotlinLibraryLayoutImpl(klib)
|
||||||
|
|
||||||
fun <T> realFiles(action: (L) -> T): T =
|
fun <T> realFiles(action: (L) -> T): T =
|
||||||
if (layout.isZipped)
|
if (layout.isZipped)
|
||||||
@@ -71,12 +71,12 @@ open class BaseLibraryAccess<L : KotlinLibraryLayout>(val klib: File, component:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
open class MetadataLibraryAccess<L : KotlinLibraryLayout>(klib: File, component: String) : BaseLibraryAccess<L>(klib, component) {
|
open class MetadataLibraryAccess<L : KotlinLibraryLayout>(klib: File) : BaseLibraryAccess<L>(klib) {
|
||||||
override val layout = MetadataLibraryLayoutImpl(klib, component)
|
override val layout = MetadataLibraryLayoutImpl(klib)
|
||||||
}
|
}
|
||||||
|
|
||||||
open class IrLibraryAccess<L : KotlinLibraryLayout>(klib: File, component: String) : BaseLibraryAccess<L>(klib, component) {
|
open class IrLibraryAccess<L : KotlinLibraryLayout>(klib: File) : BaseLibraryAccess<L>(klib) {
|
||||||
override val layout = IrLibraryLayoutImpl(klib, component)
|
override val layout = IrLibraryLayoutImpl(klib)
|
||||||
}
|
}
|
||||||
|
|
||||||
open class FromZipBaseLibraryImpl(zipped: KotlinLibraryLayoutImpl, zipFileSystem: FileSystem) :
|
open class FromZipBaseLibraryImpl(zipped: KotlinLibraryLayoutImpl, zipFileSystem: FileSystem) :
|
||||||
@@ -84,7 +84,6 @@ open class FromZipBaseLibraryImpl(zipped: KotlinLibraryLayoutImpl, zipFileSystem
|
|||||||
|
|
||||||
override val libraryName = zipped.libraryName
|
override val libraryName = zipped.libraryName
|
||||||
override val libDir = zipFileSystem.file(zipped.libDir)
|
override val libDir = zipFileSystem.file(zipped.libDir)
|
||||||
override val component = zipped.component
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FromZipMetadataLibraryImpl(zipped: MetadataLibraryLayoutImpl, zipFileSystem: FileSystem) :
|
class FromZipMetadataLibraryImpl(zipped: MetadataLibraryLayoutImpl, zipFileSystem: FileSystem) :
|
||||||
@@ -114,7 +113,6 @@ fun KotlinLibraryLayoutImpl.extractDir(directory: File): File = this.klib.withZi
|
|||||||
open class ExtractingKotlinLibraryLayout(zipped: KotlinLibraryLayoutImpl) : KotlinLibraryLayout {
|
open class ExtractingKotlinLibraryLayout(zipped: KotlinLibraryLayoutImpl) : KotlinLibraryLayout {
|
||||||
override val libDir: File get() = error("Extracting layout doesn't extract its own root")
|
override val libDir: File get() = error("Extracting layout doesn't extract its own root")
|
||||||
override val libraryName = zipped.libraryName
|
override val libraryName = zipped.libraryName
|
||||||
override val component = zipped.component
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open class ExtractingBaseLibraryImpl(zipped: KotlinLibraryLayoutImpl) :
|
open class ExtractingBaseLibraryImpl(zipped: KotlinLibraryLayoutImpl) :
|
||||||
|
|||||||
@@ -11,11 +11,8 @@ import org.jetbrains.kotlin.konan.properties.Properties
|
|||||||
import org.jetbrains.kotlin.konan.properties.saveToFile
|
import org.jetbrains.kotlin.konan.properties.saveToFile
|
||||||
import org.jetbrains.kotlin.library.*
|
import org.jetbrains.kotlin.library.*
|
||||||
|
|
||||||
const val KLIB_DEFAULT_COMPONENT_NAME = "default"
|
|
||||||
|
|
||||||
open class KotlinLibraryLayoutForWriter(
|
open class KotlinLibraryLayoutForWriter(
|
||||||
override val libDir: File,
|
override val libDir: File
|
||||||
override val component: String = KLIB_DEFAULT_COMPONENT_NAME
|
|
||||||
) : KotlinLibraryLayout, MetadataKotlinLibraryLayout, IrKotlinLibraryLayout
|
) : KotlinLibraryLayout, MetadataKotlinLibraryLayout, IrKotlinLibraryLayout
|
||||||
|
|
||||||
open class BaseWriterImpl(
|
open class BaseWriterImpl(
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.konan.library.KonanFactories
|
|||||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.isInterop
|
import org.jetbrains.kotlin.library.isInterop
|
||||||
import org.jetbrains.kotlin.library.resolveSingleFileKlib
|
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
import org.jetbrains.kotlin.platform.impl.NativeIdePlatformKind
|
import org.jetbrains.kotlin.platform.impl.NativeIdePlatformKind
|
||||||
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
|
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
|
||||||
@@ -189,7 +188,7 @@ class NativeLibraryInfo(project: Project, library: Library, val libraryRoot: Str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val nativeLibrary = resolveSingleFileKlib(File(libraryRoot))
|
private val nativeLibrary = createKotlinLibrary(File(libraryRoot))
|
||||||
|
|
||||||
val isStdlib get() = libraryRoot.endsWith(KONAN_STDLIB_NAME)
|
val isStdlib get() = libraryRoot.endsWith(KONAN_STDLIB_NAME)
|
||||||
val metadataInfo by lazy {
|
val metadataInfo by lazy {
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.library.KotlinLibrary
|
|||||||
import org.jetbrains.kotlin.library.SerializedMetadata
|
import org.jetbrains.kotlin.library.SerializedMetadata
|
||||||
import org.jetbrains.kotlin.library.impl.BaseWriterImpl
|
import org.jetbrains.kotlin.library.impl.BaseWriterImpl
|
||||||
import org.jetbrains.kotlin.library.impl.KoltinLibraryWriterImpl
|
import org.jetbrains.kotlin.library.impl.KoltinLibraryWriterImpl
|
||||||
import org.jetbrains.kotlin.library.resolveSingleFileKlib
|
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.serialization.konan.impl.KlibResolvedModuleDescriptorsFactoryImpl
|
import org.jetbrains.kotlin.serialization.konan.impl.KlibResolvedModuleDescriptorsFactoryImpl
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
@@ -143,7 +143,7 @@ class NativeDistributionCommonizer(
|
|||||||
if (!location.isDirectory)
|
if (!location.isDirectory)
|
||||||
handleError("library not found: $location")
|
handleError("library not found: $location")
|
||||||
|
|
||||||
val library = resolveSingleFileKlib(KFile(location.path))
|
val library = createKotlinLibrary(KFile(location.path))
|
||||||
|
|
||||||
if (library.versions.metadataVersion == null)
|
if (library.versions.metadataVersion == null)
|
||||||
handleError("library does not have metadata version specified in manifest: $location")
|
handleError("library does not have metadata version specified in manifest: $location")
|
||||||
|
|||||||
@@ -68,11 +68,10 @@ class Distribution(
|
|||||||
|
|
||||||
val klib = "$konanHome/klib"
|
val klib = "$konanHome/klib"
|
||||||
val stdlib = "$klib/common/stdlib"
|
val stdlib = "$klib/common/stdlib"
|
||||||
val stdlibDefaultComponent = "$stdlib/default"
|
|
||||||
|
|
||||||
fun defaultNatives(target: KonanTarget) = "$konanHome/konan/targets/${target.visibleName}/native"
|
fun defaultNatives(target: KonanTarget) = "$konanHome/konan/targets/${target.visibleName}/native"
|
||||||
|
|
||||||
fun runtime(target: KonanTarget) = runtimeFileOverride ?: "$stdlibDefaultComponent/targets/${target.visibleName}/native/runtime.bc"
|
fun runtime(target: KonanTarget) = runtimeFileOverride ?: "$stdlib/targets/${target.visibleName}/native/runtime.bc"
|
||||||
|
|
||||||
val launcherFiles = listOf("launcher.bc")
|
val launcherFiles = listOf("launcher.bc")
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.konan.target.CompilerOutputKind.*
|
|||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.resolveSingleFileKlib
|
|
||||||
import org.jetbrains.kotlin.library.uniqueName
|
import org.jetbrains.kotlin.library.uniqueName
|
||||||
import org.jetbrains.kotlin.library.unresolvedDependencies
|
import org.jetbrains.kotlin.library.unresolvedDependencies
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -729,7 +728,7 @@ class CacheBuilder(val project: Project, val binary: NativeBinary) {
|
|||||||
cacheDirectory.mkdirs()
|
cacheDirectory.mkdirs()
|
||||||
|
|
||||||
val artifactsLibraries = artifactsToAddToCache
|
val artifactsLibraries = artifactsToAddToCache
|
||||||
.map { resolveSingleFileKlib(org.jetbrains.kotlin.konan.file.File(it.file.absolutePath)) }
|
.map { createKotlinLibrary(org.jetbrains.kotlin.konan.file.File(it.file.absolutePath)) }
|
||||||
.associateBy { it.uniqueName }
|
.associateBy { it.uniqueName }
|
||||||
|
|
||||||
// Top sort artifacts.
|
// Top sort artifacts.
|
||||||
@@ -798,7 +797,7 @@ class CacheBuilder(val project: Project, val binary: NativeBinary) {
|
|||||||
val platformLib = platformLibs[platformLibName] ?: error("$platformLibName is not found in platform libs")
|
val platformLib = platformLibs[platformLibName] ?: error("$platformLibName is not found in platform libs")
|
||||||
if (File(rootCacheDirectory, platformLibName.cachedName).exists())
|
if (File(rootCacheDirectory, platformLibName.cachedName).exists())
|
||||||
return
|
return
|
||||||
for (dependency in resolveSingleFileKlib(org.jetbrains.kotlin.konan.file.File(platformLib.absolutePath)).unresolvedDependencies)
|
for (dependency in createKotlinLibrary(org.jetbrains.kotlin.konan.file.File(platformLib.absolutePath)).unresolvedDependencies)
|
||||||
ensureCompilerProvidedLibPrecached(dependency.path, platformLibs, visitedLibs)
|
ensureCompilerProvidedLibPrecached(dependency.path, platformLibs, visitedLibs)
|
||||||
project.logger.info("Compiling $platformLibName (${visitedLibs.size}/${platformLibs.size}) to cache")
|
project.logger.info("Compiling $platformLibName (${visitedLibs.size}/${platformLibs.size}) to cache")
|
||||||
val args = mutableListOf(
|
val args = mutableListOf(
|
||||||
|
|||||||
Reference in New Issue
Block a user