Pass compiler args from facets when compiling in fallback mode from JPS
Original commit: 58fd2530d2
This commit is contained in:
@@ -88,14 +88,13 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
environment: JpsCompilerEnvironment
|
environment: JpsCompilerEnvironment
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
environment.messageCollector.report(CompilerMessageSeverity.INFO, "Using kotlin-home = " + environment.kotlinPaths.homePath, CompilerMessageLocation.NO_LOCATION)
|
environment.messageCollector.report(CompilerMessageSeverity.INFO, "Using kotlin-home = " + environment.kotlinPaths.homePath, CompilerMessageLocation.NO_LOCATION)
|
||||||
val argsArray = ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray()
|
|
||||||
|
|
||||||
return if (isDaemonEnabled()) {
|
return if (isDaemonEnabled()) {
|
||||||
val daemonExitCode = compileWithDaemon(compilerClassName, compilerArgs, environment)
|
val daemonExitCode = compileWithDaemon(compilerClassName, compilerArgs, environment)
|
||||||
daemonExitCode ?: fallbackCompileStrategy(argsArray, compilerClassName, environment)
|
daemonExitCode ?: fallbackCompileStrategy(compilerArgs, compilerClassName, environment)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fallbackCompileStrategy(argsArray, compilerClassName, environment)
|
fallbackCompileStrategy(compilerArgs, compilerClassName, environment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,14 +114,18 @@ 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 allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) +
|
daemon.compile(sessionId, withAdditionalCompilerArgs(compilerArgs), options, JpsCompilerServicesFacadeImpl(environment), null)
|
||||||
(compilerSettings?.additionalArguments?.split(" ") ?: emptyList())
|
|
||||||
daemon.compile(sessionId, allArgs.toTypedArray(), options, JpsCompilerServicesFacadeImpl(environment), null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
return res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun withAdditionalCompilerArgs(compilerArgs: CommonCompilerArguments): Array<String> {
|
||||||
|
val allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) +
|
||||||
|
(compilerSettings?.additionalArguments?.split(" ") ?: emptyList())
|
||||||
|
return allArgs.toTypedArray()
|
||||||
|
}
|
||||||
|
|
||||||
private fun reportCategories(verbose: Boolean): Array<Int> {
|
private fun reportCategories(verbose: Boolean): Array<Int> {
|
||||||
val categories =
|
val categories =
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
@@ -145,7 +148,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fallbackCompileStrategy(
|
private fun fallbackCompileStrategy(
|
||||||
argsArray: Array<String>,
|
compilerArgs: CommonCompilerArguments,
|
||||||
compilerClassName: String,
|
compilerClassName: String,
|
||||||
environment: JpsCompilerEnvironment
|
environment: JpsCompilerEnvironment
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
@@ -161,7 +164,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, 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,
|
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user