Do not parse/serialize additional compiler arguments in JPS

This is mostly a revert of f936dea8, where the issue of the compiler
failing on repeated command line arguments was worked around. Now the
compiler behaves more properly: it uses the last passed argument and its
value, and prints a warning that several values have been passed. With
this behavior, the workaround is no longer necessary

Original commit: dc5e51f4ac
This commit is contained in:
Alexander Udalov
2017-04-14 20:30:24 +03:00
parent abacf2845f
commit 7f8b88fee2
@@ -138,21 +138,14 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
val compilerMode = CompilerMode.JPS_COMPILER val compilerMode = CompilerMode.JPS_COMPILER
val verbose = compilerArgs.verbose val verbose = compilerArgs.verbose
val options = CompilationOptions(compilerMode, targetPlatform, reportCategories(verbose), reportSeverity(verbose), requestedCompilationResults = emptyArray()) val options = CompilationOptions(compilerMode, targetPlatform, reportCategories(verbose), reportSeverity(verbose), requestedCompilationResults = emptyArray())
val res = daemon.compile(sessionId, serializeWithAdditionalCompilerArgs(compilerArgs), options, JpsCompilerServicesFacadeImpl(environment), null) val res = daemon.compile(sessionId, withAdditionalCompilerArgs(compilerArgs), options, JpsCompilerServicesFacadeImpl(environment), null)
return exitCodeFromProcessExitCode(res.get()) return exitCodeFromProcessExitCode(res.get())
} }
private fun withAdditionalArguments(compilerArgs: CommonCompilerArguments): CommonCompilerArguments { private fun withAdditionalCompilerArgs(compilerArgs: CommonCompilerArguments): Array<String> {
val compilerSettings = compilerSettings ?: return compilerArgs val allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) +
return copyBean(compilerArgs).apply { (compilerSettings?.additionalArgumentsAsList ?: emptyList())
parseArguments(compilerSettings.additionalArgumentsAsList.toTypedArray(), this) return allArgs.toTypedArray()
freeArgs.addAll(0, compilerArgs.freeArgs)
unknownExtraFlags.addAll(0, compilerArgs.unknownExtraFlags)
}
}
private fun serializeWithAdditionalCompilerArgs(compilerArgs: CommonCompilerArguments): Array<String> {
return ArgumentUtils.convertArgumentsToStringList(withAdditionalArguments(compilerArgs)).toTypedArray()
} }
private fun reportCategories(verbose: Boolean): Array<Int> { private fun reportCategories(verbose: Boolean): Array<Int> {
@@ -193,7 +186,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
if (System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false").toBoolean()) if (System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false").toBoolean())
System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "true") System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "true")
val rc = CompilerRunnerUtil.invokeExecMethod(compilerClassName, serializeWithAdditionalCompilerArgs(compilerArgs), 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, // exec() returns an ExitCode object, class of which is loaded with a different class loader,
// so we take it's contents through reflection // so we take it's contents through reflection