Don't use global state for keeping incremental compilation state

Previously IC state was stored in System properties. As result parallel
compilation might cause incorrect state of IC, what led to corruption
of kotlin_module files. Now IC state is stored via CompilerArguments
and CompilerConfiguration
#KT-46038 Fixed
This commit is contained in:
Andrey Uskov
2021-09-20 21:17:18 +03:00
committed by teamcity
parent 99300bd885
commit 2adc851f1b
21 changed files with 98 additions and 32 deletions
@@ -66,6 +66,7 @@ import java.util.stream.Collectors;
import static org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR;
import static org.jetbrains.kotlin.cli.common.ExitCode.OK;
import static org.jetbrains.kotlin.cli.common.UtilsKt.getLibraryFromHome;
import static org.jetbrains.kotlin.cli.common.UtilsKt.incrementalCompilationIsEnabledForJs;
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*;
public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
@@ -181,7 +182,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
return exitCode;
}
if (arguments.getFreeArgs().isEmpty() && !IncrementalCompilation.isEnabledForJs()) {
if (arguments.getFreeArgs().isEmpty() && (!incrementalCompilationIsEnabledForJs(arguments))) {
if (arguments.getVersion()) {
return OK;
}
@@ -219,7 +220,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
return ExitCode.COMPILATION_ERROR;
}
if (sourcesFiles.isEmpty() && !IncrementalCompilation.isEnabledForJs()) {
if (sourcesFiles.isEmpty() && !incrementalCompilationIsEnabledForJs(arguments)) {
messageCollector.report(ERROR, "No source files", null);
return COMPILATION_ERROR;
}
@@ -114,7 +114,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
return scriptingEvaluator.eval(arguments, configuration, projectEnv)
}
if (arguments.freeArgs.isEmpty() && !IncrementalCompilation.isEnabledForJs()) {
if (arguments.freeArgs.isEmpty() && !(incrementalCompilationIsEnabledForJs(arguments))) {
if (arguments.version) {
return OK
}
@@ -166,7 +166,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
return ExitCode.COMPILATION_ERROR
}
if (sourcesFiles.isEmpty() && !IncrementalCompilation.isEnabledForJs() && arguments.includes.isNullOrEmpty()) {
if (sourcesFiles.isEmpty() && (!incrementalCompilationIsEnabledForJs(arguments)) && arguments.includes.isNullOrEmpty()) {
messageCollector.report(ERROR, "No source files", null)
return COMPILATION_ERROR
}