Move KonanLibraryWriter and its friends to the shared package.
This commit is contained in:
committed by
Sergey Bogolepov
parent
c675fff032
commit
496ebbe2a8
+13
-14
@@ -5,7 +5,6 @@
|
||||
package org.jetbrains.kotlin.backend.konan
|
||||
|
||||
import llvm.*
|
||||
import org.jetbrains.kotlin.backend.konan.library.impl.buildLibrary
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.*
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.Llvm
|
||||
import org.jetbrains.kotlin.konan.CURRENT
|
||||
@@ -15,6 +14,7 @@ import org.jetbrains.kotlin.konan.file.isBitcode
|
||||
import org.jetbrains.kotlin.library.*
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.konan.library.impl.buildLibrary
|
||||
|
||||
/**
|
||||
* Supposed to be true for a single LLVM module within final binary.
|
||||
@@ -139,19 +139,18 @@ internal fun produceOutput(context: Context) {
|
||||
val manifestProperties = context.config.manifestProperties
|
||||
|
||||
val library = buildLibrary(
|
||||
context.config.nativeLibraries,
|
||||
context.config.includeBinaries,
|
||||
neededLibraries,
|
||||
context.serializedMetadata!!,
|
||||
context.serializedIr!!,
|
||||
versions,
|
||||
target,
|
||||
output,
|
||||
libraryName,
|
||||
null,
|
||||
nopack,
|
||||
manifestProperties,
|
||||
context.dataFlowGraph)
|
||||
context.config.nativeLibraries,
|
||||
context.config.includeBinaries,
|
||||
neededLibraries,
|
||||
context.serializedMetadata!!,
|
||||
context.serializedIr!!,
|
||||
versions,
|
||||
target,
|
||||
output,
|
||||
libraryName,
|
||||
nopack,
|
||||
manifestProperties,
|
||||
context.dataFlowGraph)
|
||||
|
||||
context.bitcodeFileName = library.mainBitcodeFileName
|
||||
}
|
||||
|
||||
+1
-3
@@ -3,9 +3,8 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.library
|
||||
package org.jetbrains.kotlin.konan.library
|
||||
|
||||
import llvm.LLVMModuleRef
|
||||
import org.jetbrains.kotlin.library.BaseWriter
|
||||
import org.jetbrains.kotlin.library.IrWriter
|
||||
import org.jetbrains.kotlin.library.MetadataWriter
|
||||
@@ -15,7 +14,6 @@ interface TargetedWriter {
|
||||
}
|
||||
|
||||
interface BitcodeWriter : TargetedWriter {
|
||||
fun addKotlinBitcode(llvmModule: LLVMModuleRef)
|
||||
fun addNativeBitcode(library: String)
|
||||
}
|
||||
|
||||
+2
-9
@@ -3,11 +3,9 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.library.impl
|
||||
package org.jetbrains.kotlin.konan.library.impl
|
||||
|
||||
import llvm.LLVMModuleRef
|
||||
import llvm.LLVMWriteBitcodeToFile
|
||||
import org.jetbrains.kotlin.backend.konan.library.BitcodeWriter
|
||||
import org.jetbrains.kotlin.konan.library.BitcodeWriter
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.konan.library.BitcodeKotlinLibraryLayout
|
||||
import org.jetbrains.kotlin.konan.library.TargetedKotlinLibraryLayout
|
||||
@@ -39,9 +37,4 @@ class BitcodeWriterImpl(
|
||||
val basename = File(library).name
|
||||
File(library).copyTo(File(bitcodeLayout.nativeDir, basename))
|
||||
}
|
||||
|
||||
override fun addKotlinBitcode(llvmModule: LLVMModuleRef) {
|
||||
//libraryLayout.llvmModule = llvmModule
|
||||
LLVMWriteBitcodeToFile(llvmModule, bitcodeLayout.mainBitcodeFileName)
|
||||
}
|
||||
}
|
||||
+14
-17
@@ -3,11 +3,10 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.library.impl
|
||||
package org.jetbrains.kotlin.konan.library.impl
|
||||
|
||||
import llvm.LLVMModuleRef
|
||||
import org.jetbrains.kotlin.backend.konan.library.BitcodeWriter
|
||||
import org.jetbrains.kotlin.backend.konan.library.KonanLibraryWriter
|
||||
import org.jetbrains.kotlin.konan.library.BitcodeWriter
|
||||
import org.jetbrains.kotlin.konan.library.KonanLibraryWriter
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.konan.library.KonanLibrary
|
||||
import org.jetbrains.kotlin.konan.library.KonanLibraryLayout
|
||||
@@ -26,22 +25,22 @@ class KonanLibraryLayoutForWriter(
|
||||
* Requires non-null [target].
|
||||
*/
|
||||
class KonanLibraryWriterImpl(
|
||||
libDir: File,
|
||||
moduleName: String,
|
||||
versions: KonanLibraryVersioning,
|
||||
target: KonanTarget,
|
||||
nopack: Boolean = false,
|
||||
libDir: File,
|
||||
moduleName: String,
|
||||
versions: KonanLibraryVersioning,
|
||||
target: KonanTarget,
|
||||
nopack: Boolean = false,
|
||||
|
||||
val layout: KonanLibraryLayoutForWriter = KonanLibraryLayoutForWriter(libDir, target),
|
||||
val layout: KonanLibraryLayoutForWriter = KonanLibraryLayoutForWriter(libDir, target),
|
||||
|
||||
base: BaseWriter = BaseWriterImpl(layout, moduleName, versions, nopack),
|
||||
bitcode: BitcodeWriter = BitcodeWriterImpl(layout),
|
||||
metadata: MetadataWriter = MetadataWriterImpl(layout),
|
||||
ir: IrWriter = IrMonoliticWriterImpl(layout)
|
||||
base: BaseWriter = BaseWriterImpl(layout, moduleName, versions, nopack),
|
||||
bitcode: BitcodeWriter = BitcodeWriterImpl(layout),
|
||||
metadata: MetadataWriter = MetadataWriterImpl(layout),
|
||||
ir: IrWriter = IrMonoliticWriterImpl(layout)
|
||||
|
||||
) : BaseWriter by base, BitcodeWriter by bitcode, MetadataWriter by metadata, IrWriter by ir, KonanLibraryWriter
|
||||
|
||||
internal fun buildLibrary(
|
||||
fun buildLibrary(
|
||||
natives: List<String>,
|
||||
included: List<String>,
|
||||
linkDependencies: List<KonanLibrary>,
|
||||
@@ -51,7 +50,6 @@ internal fun buildLibrary(
|
||||
target: KonanTarget,
|
||||
output: String,
|
||||
moduleName: String,
|
||||
llvmModule: LLVMModuleRef?,
|
||||
nopack: Boolean,
|
||||
manifestProperties: Properties?,
|
||||
dataFlowGraph: ByteArray?
|
||||
@@ -59,7 +57,6 @@ internal fun buildLibrary(
|
||||
|
||||
val library = KonanLibraryWriterImpl(File(output), moduleName, versions, target, nopack)
|
||||
|
||||
llvmModule?.let { library.addKotlinBitcode(it) }
|
||||
library.addMetadata(metadata)
|
||||
library.addIr(ir)
|
||||
|
||||
Reference in New Issue
Block a user