Do not parse/serialize additional compiler arguments in JPS
This is mostly a revert off936dea8, 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:
@@ -138,21 +138,14 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||
val compilerMode = CompilerMode.JPS_COMPILER
|
||||
val verbose = compilerArgs.verbose
|
||||
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())
|
||||
}
|
||||
|
||||
private fun withAdditionalArguments(compilerArgs: CommonCompilerArguments): CommonCompilerArguments {
|
||||
val compilerSettings = compilerSettings ?: return compilerArgs
|
||||
return copyBean(compilerArgs).apply {
|
||||
parseArguments(compilerSettings.additionalArgumentsAsList.toTypedArray(), this)
|
||||
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 withAdditionalCompilerArgs(compilerArgs: CommonCompilerArguments): Array<String> {
|
||||
val allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) +
|
||||
(compilerSettings?.additionalArgumentsAsList ?: emptyList())
|
||||
return allArgs.toTypedArray()
|
||||
}
|
||||
|
||||
private fun reportCategories(verbose: Boolean): Array<Int> {
|
||||
@@ -193,7 +186,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||
if (System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false").toBoolean())
|
||||
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,
|
||||
// so we take it's contents through reflection
|
||||
|
||||
Reference in New Issue
Block a user