Initial implementation of klib components.
(cherry picked from commit e1db35b825dabc5eb8f48a24fe6a46b0a0e87714)
This commit is contained in:
committed by
Vasily Levchenko
parent
40154e60e3
commit
b4882103bc
+4
-3
@@ -402,6 +402,7 @@ task distEndorsedLibraries {
|
||||
}
|
||||
|
||||
def stdlib = 'klib/common/stdlib'
|
||||
def stdlibDefaultComponent = "$stdlib/default"
|
||||
def endorsedLibs = 'klib/common/endorsedLibraries'
|
||||
def endorsedLibsBase = 'klib/common'
|
||||
|
||||
@@ -437,7 +438,7 @@ targetList.each { target ->
|
||||
|
||||
from(project(':runtime').file("build/$target")) {
|
||||
include("runtime.bc")
|
||||
into("$stdlib/targets/$target/native")
|
||||
into("$stdlibDefaultComponent/targets/$target/native")
|
||||
}
|
||||
from(project(':runtime').file("build/$target")) {
|
||||
include("*.bc")
|
||||
@@ -446,10 +447,10 @@ targetList.each { target ->
|
||||
}
|
||||
from(project(':runtime').file("build/${target}Stdlib")) {
|
||||
include('**')
|
||||
into(stdlib)
|
||||
into(stdlibDefaultComponent)
|
||||
}
|
||||
if (target == 'wasm32') {
|
||||
into("$stdlib/targets/wasm32/included") {
|
||||
into("$stdlibDefaultComponent/targets/wasm32/included") {
|
||||
from(project(':runtime').file('src/main/js'))
|
||||
from(project(':runtime').file('src/launcher/js'))
|
||||
from(project(':Interop:JsRuntime').file('src/main/js'))
|
||||
|
||||
@@ -22,13 +22,12 @@ import org.jetbrains.kotlin.library.IrKotlinLibraryLayout
|
||||
import org.jetbrains.kotlin.library.KotlinLibraryLayout
|
||||
import org.jetbrains.kotlin.library.MetadataKotlinLibraryLayout
|
||||
|
||||
|
||||
interface TargetedKotlinLibraryLayout : KotlinLibraryLayout {
|
||||
val target: KonanTarget?
|
||||
// This is a default implementation. Can't make it an assignment.
|
||||
get() = null
|
||||
val targetsDir
|
||||
get() = File(libDir, "targets")
|
||||
get() = File(componentDir, "targets")
|
||||
val targetDir
|
||||
get() = File(targetsDir, target!!.visibleName)
|
||||
val includedDir
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.jetbrains.kotlin.konan.library
|
||||
import org.jetbrains.kotlin.konan.CompilerVersion
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.konan.library.impl.KonanLibraryImpl
|
||||
import org.jetbrains.kotlin.konan.library.impl.createKonanLibrary
|
||||
import org.jetbrains.kotlin.konan.library.impl.createKonanLibraryComponents
|
||||
import org.jetbrains.kotlin.konan.target.Distribution
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.library.*
|
||||
@@ -60,7 +60,7 @@ fun resolverByName(
|
||||
skipCurrentDir,
|
||||
logger
|
||||
) {
|
||||
override fun libraryBuilder(file: File, isDefault: Boolean) = createKonanLibrary(file, null, isDefault)
|
||||
override fun libraryComponentBuilder(file: File, isDefault: Boolean) = createKonanLibraryComponents(file, null, isDefault)
|
||||
}
|
||||
|
||||
internal class KonanLibraryProperResolver(
|
||||
@@ -84,7 +84,7 @@ internal class KonanLibraryProperResolver(
|
||||
listOf(KLIB_INTEROP_IR_PROVIDER_IDENTIFIER)
|
||||
), SearchPathResolverWithTarget<KonanLibrary>
|
||||
{
|
||||
override fun libraryBuilder(file: File, isDefault: Boolean) = createKonanLibrary(file, target, isDefault)
|
||||
override fun libraryComponentBuilder(file: File, isDefault: Boolean) = createKonanLibraryComponents(file, target, isDefault)
|
||||
|
||||
override val distPlatformHead: File?
|
||||
get() = distributionKlib?.File()?.child("platform")?.child(target.visibleName)
|
||||
|
||||
+18
-5
@@ -89,14 +89,15 @@ class KonanLibraryImpl(
|
||||
|
||||
fun createKonanLibrary(
|
||||
libraryFile: File,
|
||||
component: String,
|
||||
target: KonanTarget? = null,
|
||||
isDefault: Boolean = false
|
||||
): KonanLibrary {
|
||||
val baseAccess = BaseLibraryAccess<KotlinLibraryLayout>(libraryFile)
|
||||
val targetedAccess = TargetedLibraryAccess<TargetedKotlinLibraryLayout>(libraryFile, target)
|
||||
val metadataAccess = MetadataLibraryAccess<MetadataKotlinLibraryLayout>(libraryFile)
|
||||
val irAccess = IrLibraryAccess<IrKotlinLibraryLayout>(libraryFile)
|
||||
val bitcodeAccess = BitcodeLibraryAccess<BitcodeKotlinLibraryLayout>(libraryFile, target)
|
||||
val baseAccess = BaseLibraryAccess<KotlinLibraryLayout>(libraryFile, component)
|
||||
val targetedAccess = TargetedLibraryAccess<TargetedKotlinLibraryLayout>(libraryFile, component, target)
|
||||
val metadataAccess = MetadataLibraryAccess<MetadataKotlinLibraryLayout>(libraryFile, component)
|
||||
val irAccess = IrLibraryAccess<IrKotlinLibraryLayout>(libraryFile, component)
|
||||
val bitcodeAccess = BitcodeLibraryAccess<BitcodeKotlinLibraryLayout>(libraryFile, component, target)
|
||||
|
||||
val base = BaseKotlinLibraryImpl(baseAccess, isDefault)
|
||||
val targeted = TargetedLibraryImpl(targetedAccess, base)
|
||||
@@ -106,3 +107,15 @@ fun createKonanLibrary(
|
||||
|
||||
return KonanLibraryImpl(targeted, metadata, ir, bitcode)
|
||||
}
|
||||
|
||||
fun createKonanLibraryComponents(
|
||||
libraryFile: File,
|
||||
target: KonanTarget? = null,
|
||||
isDefault: Boolean = true
|
||||
) : List<KonanLibrary> {
|
||||
val baseAccess = BaseLibraryAccess<KotlinLibraryLayout>(libraryFile, null)
|
||||
val base = BaseKotlinLibraryImpl(baseAccess, isDefault)
|
||||
return base.componentList.map {
|
||||
createKonanLibrary(libraryFile, it, target, isDefault)
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -7,8 +7,8 @@ import org.jetbrains.kotlin.library.*
|
||||
import org.jetbrains.kotlin.library.impl.*
|
||||
import java.nio.file.FileSystem
|
||||
|
||||
open class TargetedLibraryLayoutImpl(klib: File, override val target: KonanTarget?) :
|
||||
KotlinLibraryLayoutImpl(klib), TargetedKotlinLibraryLayout {
|
||||
open class TargetedLibraryLayoutImpl(klib: File, component: String, override val target: KonanTarget?) :
|
||||
KotlinLibraryLayoutImpl(klib, component), TargetedKotlinLibraryLayout {
|
||||
|
||||
override val extractingToTemp: TargetedKotlinLibraryLayout by lazy {
|
||||
ExtractingTargetedLibraryImpl(this)
|
||||
@@ -19,8 +19,8 @@ open class TargetedLibraryLayoutImpl(klib: File, override val target: KonanTarge
|
||||
|
||||
}
|
||||
|
||||
class BitcodeLibraryLayoutImpl(klib: File, target: KonanTarget?) : TargetedLibraryLayoutImpl(klib, target),
|
||||
BitcodeKotlinLibraryLayout {
|
||||
class BitcodeLibraryLayoutImpl(klib: File, component: String, target: KonanTarget?) :
|
||||
TargetedLibraryLayoutImpl(klib, component, target), BitcodeKotlinLibraryLayout {
|
||||
override val extractingToTemp: BitcodeKotlinLibraryLayout by lazy {
|
||||
ExtractingBitcodeLibraryImpl(this)
|
||||
}
|
||||
@@ -30,14 +30,14 @@ class BitcodeLibraryLayoutImpl(klib: File, target: KonanTarget?) : TargetedLibra
|
||||
|
||||
}
|
||||
|
||||
open class TargetedLibraryAccess<L : KotlinLibraryLayout>(klib: File, val target: KonanTarget?) :
|
||||
BaseLibraryAccess<L>(klib) {
|
||||
override val layout = TargetedLibraryLayoutImpl(klib, target)
|
||||
open class TargetedLibraryAccess<L : KotlinLibraryLayout>(klib: File, component: String, val target: KonanTarget?) :
|
||||
BaseLibraryAccess<L>(klib, component) {
|
||||
override val layout = TargetedLibraryLayoutImpl(klib, component, target)
|
||||
}
|
||||
|
||||
open class BitcodeLibraryAccess<L : KotlinLibraryLayout>(klib: File, target: KonanTarget?) :
|
||||
TargetedLibraryAccess<L>(klib, target) {
|
||||
override val layout = BitcodeLibraryLayoutImpl(klib, target)
|
||||
open class BitcodeLibraryAccess<L : KotlinLibraryLayout>(klib: File, component: String, target: KonanTarget?) :
|
||||
TargetedLibraryAccess<L>(klib, component, target) {
|
||||
override val layout = BitcodeLibraryLayoutImpl(klib, component, target)
|
||||
}
|
||||
|
||||
private open class FromZipTargetedLibraryImpl(zipped: TargetedLibraryLayoutImpl, zipFileSystem: FileSystem) :
|
||||
|
||||
Reference in New Issue
Block a user