Compile multiplatform projects with daemon
This commit is contained in:
+2
@@ -47,6 +47,7 @@ interface KotlinLogger {
|
||||
abstract class KotlinCompilerRunner<in Env : CompilerEnvironment> {
|
||||
protected val K2JVM_COMPILER = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
||||
protected val K2JS_COMPILER = "org.jetbrains.kotlin.cli.js.K2JSCompiler"
|
||||
protected val K2METADATA_COMPILER = "org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler"
|
||||
protected val INTERNAL_ERROR = ExitCode.INTERNAL_ERROR.toString()
|
||||
|
||||
protected abstract val log: KotlinLogger
|
||||
@@ -148,6 +149,7 @@ abstract class KotlinCompilerRunner<in Env : CompilerEnvironment> {
|
||||
val targetPlatform = when (compilerClassName) {
|
||||
K2JVM_COMPILER -> CompileService.TargetPlatform.JVM
|
||||
K2JS_COMPILER -> CompileService.TargetPlatform.JS
|
||||
K2METADATA_COMPILER -> CompileService.TargetPlatform.METADATA
|
||||
else -> throw IllegalArgumentException("Unknown compiler type $compilerClassName")
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -31,7 +31,8 @@ interface CompileService : Remote {
|
||||
|
||||
enum class TargetPlatform : Serializable {
|
||||
JVM,
|
||||
JS
|
||||
JS,
|
||||
METADATA
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.daemon
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
import org.jetbrains.kotlin.daemon.common.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
@@ -125,9 +126,11 @@ object KotlinCompileDaemon {
|
||||
val compilerSelector = object : CompilerSelector {
|
||||
private val jvm by lazy { K2JVMCompiler() }
|
||||
private val js by lazy { K2JSCompiler() }
|
||||
private val metadata by lazy { K2MetadataCompiler() }
|
||||
override fun get(targetPlatform: CompileService.TargetPlatform): CLICompiler<*> = when (targetPlatform) {
|
||||
CompileService.TargetPlatform.JVM -> jvm
|
||||
CompileService.TargetPlatform.JS -> js
|
||||
CompileService.TargetPlatform.METADATA -> metadata
|
||||
}
|
||||
}
|
||||
// timer with a daemon thread, meaning it should not prevent JVM to exit normally
|
||||
|
||||
Reference in New Issue
Block a user