Different extensions (and KonanTarget communalization). (#665)
This commit is contained in:
committed by
Nikolay Igotti
parent
c57ad51fc7
commit
d3c24bb387
@@ -18,10 +18,7 @@ package org.jetbrains.kotlin.cli.bc
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import org.jetbrains.kotlin.backend.konan.*
|
||||
import org.jetbrains.kotlin.backend.konan.CompilerOutputKind.*
|
||||
import org.jetbrains.kotlin.backend.konan.util.profile
|
||||
import org.jetbrains.kotlin.backend.konan.util.suffixIfNot
|
||||
import org.jetbrains.kotlin.backend.konan.util.removeSuffixIfPresent
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.CLITool
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
@@ -31,15 +28,16 @@ import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.config.addKotlinSourceRoots
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import java.util.*
|
||||
import kotlin.reflect.KFunction
|
||||
|
||||
// TODO: Don't use reflection?
|
||||
private fun maybeExecuteHelper(configuration: CompilerConfiguration) {
|
||||
private fun maybeExecuteHelper(targetName: String) {
|
||||
try {
|
||||
val kClass = Class.forName("org.jetbrains.kotlin.konan.Helper0").kotlin
|
||||
val ctor = kClass.constructors.single() as KFunction<Runnable>
|
||||
val distribution = Distribution(configuration)
|
||||
val distribution = Distribution(TargetManager(targetName))
|
||||
val result = ctor.call(
|
||||
distribution.dependenciesDir,
|
||||
distribution.properties.properties,
|
||||
@@ -109,18 +107,10 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
// TODO: Collect all the explicit file names into an object
|
||||
// and teach the compiler to work with temporaries and -save-temps.
|
||||
|
||||
arguments.outputName ?.let { put(OUTPUT, it) }
|
||||
val outputKind = CompilerOutputKind.valueOf(
|
||||
(arguments.produce ?: "program").toUpperCase())
|
||||
|
||||
put(PRODUCE, outputKind)
|
||||
val suffix = outputKind.suffix
|
||||
val output = arguments.outputFile?.removeSuffixIfPresent(suffix)
|
||||
?: outputKind.name.toLowerCase()
|
||||
put(OUTPUT_NAME, output)
|
||||
put(OUTPUT_FILE, output.suffixIfNot(outputKind.suffix))
|
||||
|
||||
// This is a decision we could change
|
||||
put(CommonConfigurationKeys.MODULE_NAME, output)
|
||||
put(ABI_VERSION, 1)
|
||||
|
||||
arguments.mainPackage ?.let{ put(ENTRY, it) }
|
||||
@@ -154,7 +144,7 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
}
|
||||
}
|
||||
|
||||
maybeExecuteHelper(configuration)
|
||||
maybeExecuteHelper(arguments.target ?: "host")
|
||||
}
|
||||
|
||||
override fun createArguments(): K2NativeCompilerArguments {
|
||||
|
||||
@@ -54,13 +54,13 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
||||
@field:Argument(value = "-opt", description = "Enable optimizations during compilation")
|
||||
@JvmField var optimization: Boolean = false
|
||||
|
||||
@field:Argument(value = "-output", shortName = "-o", valueDescription = "<path>", description = "Output file path")
|
||||
@JvmField var outputFile: String? = null
|
||||
@field:Argument(value = "-output", shortName = "-o", valueDescription = "<name>", description = "Output name")
|
||||
@JvmField var outputName: String? = null
|
||||
|
||||
@field:Argument(value = "-entry", shortName = "-e", valueDescription = "<name>", description = "Qualified entry point name")
|
||||
@JvmField var mainPackage: String? = null
|
||||
|
||||
@field:Argument(value = "-produce", shortName = "-p", valueDescription = "{program|library|bitcode}", description = "Produce either .kexe, .klib or a .bc file.")
|
||||
@field:Argument(value = "-produce", shortName = "-p", valueDescription = "{program|library|bitcode}", description = "Specify output file kind")
|
||||
@JvmField var produce: String? = null
|
||||
|
||||
@field:Argument(value = "-properties", valueDescription = "<path>", description = "Override standard 'konan.properties' location")
|
||||
|
||||
Reference in New Issue
Block a user