diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/KotlinCompilerRunner.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/KotlinCompilerRunner.kt index 5e69b53f678..ece6f5bdd3d 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/KotlinCompilerRunner.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/KotlinCompilerRunner.kt @@ -105,7 +105,7 @@ public object KotlinCompilerRunner { val argsArray = argumentsList.toTypedArray() - if (!tryCompileWithDaemon(messageCollector, collector, environment, argsArray)) { + if (!tryCompileWithDaemon(compilerClassName, argsArray, environment, messageCollector, collector)) { // otherwise fallback to in-process val stream = ByteArrayOutputStream() @@ -125,10 +125,10 @@ public object KotlinCompilerRunner { } - private fun tryCompileWithDaemon(messageCollector: MessageCollector, - collector: OutputItemsCollector, + private fun tryCompileWithDaemon(compilerClassName: String, + argsArray: Array, environment: CompilerEnvironment, - argsArray: Array): Boolean { + messageCollector: MessageCollector, collector: OutputItemsCollector): Boolean { if (isDaemonEnabled()) { val libPath = CompilerRunnerUtil.getLibPath(environment.kotlinPaths, messageCollector) @@ -158,7 +158,12 @@ public object KotlinCompilerRunner { val profiler = if (daemonOptions.reportPerf) WallAndThreadTotalProfiler() else DummyProfiler() - val res = KotlinCompilerClient.incrementalCompile(daemon, argsArray, services, compilerOut, daemonOut, profiler) + val targetPlatform = when (compilerClassName) { + K2JVM_COMPILER -> CompileService.TargetPlatform.JVM + K2JS_COMPILER -> CompileService.TargetPlatform.JS + else -> throw IllegalArgumentException("Unknown compiler type $compilerClassName") + } + val res = KotlinCompilerClient.incrementalCompile(daemon, targetPlatform, argsArray, services, compilerOut, daemonOut, profiler) processCompilerOutput(messageCollector, collector, compilerOut, res.toString()) BufferedReader(StringReader(daemonOut.toString())).forEachLine { diff --git a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt index f32820d9b48..920df5bb0b2 100644 --- a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt +++ b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt @@ -67,6 +67,7 @@ public class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { rebuildAll() } + // TODO: add JS tests public fun testDaemon() { System.setProperty(COMPILE_DAEMON_ENABLED_PROPERTY,"") System.setProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "")