From b841544f95b0dfaa9c194e5d53779e00cfaf6f81 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Tue, 17 Jan 2017 16:52:49 +0300 Subject: [PATCH] Pass compiler args from facets when compiling in fallback mode from JPS Original commit: 58fd2530d22f4161e3cb5f9d7080b6b1142f7225 --- .../compilerRunner/JpsKotlinCompilerRunner.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt index df4af961c7c..a557b301749 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt @@ -88,14 +88,13 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { environment: JpsCompilerEnvironment ): ExitCode { environment.messageCollector.report(CompilerMessageSeverity.INFO, "Using kotlin-home = " + environment.kotlinPaths.homePath, CompilerMessageLocation.NO_LOCATION) - val argsArray = ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray() return if (isDaemonEnabled()) { val daemonExitCode = compileWithDaemon(compilerClassName, compilerArgs, environment) - daemonExitCode ?: fallbackCompileStrategy(argsArray, compilerClassName, environment) + daemonExitCode ?: fallbackCompileStrategy(compilerArgs, compilerClassName, environment) } else { - fallbackCompileStrategy(argsArray, compilerClassName, environment) + fallbackCompileStrategy(compilerArgs, compilerClassName, environment) } } @@ -115,14 +114,18 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { val compilerMode = CompilerMode.JPS_COMPILER val verbose = compilerArgs.verbose val options = CompilationOptions(compilerMode, targetPlatform, reportCategories(verbose), reportSeverity(verbose), requestedCompilationResults = emptyArray()) - val allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) + - (compilerSettings?.additionalArguments?.split(" ") ?: emptyList()) - daemon.compile(sessionId, allArgs.toTypedArray(), options, JpsCompilerServicesFacadeImpl(environment), null) + daemon.compile(sessionId, withAdditionalCompilerArgs(compilerArgs), options, JpsCompilerServicesFacadeImpl(environment), null) } return res?.get()?.let { exitCodeFromProcessExitCode(it) } } + private fun withAdditionalCompilerArgs(compilerArgs: CommonCompilerArguments): Array { + val allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) + + (compilerSettings?.additionalArguments?.split(" ") ?: emptyList()) + return allArgs.toTypedArray() + } + private fun reportCategories(verbose: Boolean): Array { val categories = if (!verbose) { @@ -145,7 +148,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { } private fun fallbackCompileStrategy( - argsArray: Array, + compilerArgs: CommonCompilerArguments, compilerClassName: String, environment: JpsCompilerEnvironment ): ExitCode { @@ -161,7 +164,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { if (System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false").toBoolean()) System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "true") - val rc = CompilerRunnerUtil.invokeExecMethod(compilerClassName, argsArray, environment, out) + val rc = CompilerRunnerUtil.invokeExecMethod(compilerClassName, withAdditionalCompilerArgs(compilerArgs), environment, out) // exec() returns an ExitCode object, class of which is loaded with a different class loader, // so we take it's contents through reflection