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