diff --git a/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt b/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt index b9f905d6225..87d45ab7bd4 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt @@ -47,7 +47,8 @@ fun makeModuleFile( commonSources: Iterable, javaSourceRoots: Iterable, classpath: Iterable, - friendDirs: Iterable + friendDirs: Iterable, + isIncrementalMode: Boolean = true ): File { val builder = KotlinModuleXmlBuilder() builder.addModule( @@ -65,7 +66,8 @@ fun makeModuleFile( isTest, // this excludes the output directories from the class path, to be removed for true incremental compilation setOf(outputDir), - friendDirs + friendDirs, + isIncrementalMode ) val scriptFile = Files.createTempFile("kjps", sanitizeJavaIdentifier(name) + ".script.xml").toFile() diff --git a/build-common/src/org/jetbrains/kotlin/modules/KotlinModuleXmlBuilder.kt b/build-common/src/org/jetbrains/kotlin/modules/KotlinModuleXmlBuilder.kt index 3c49984c3bd..62c08b57367 100644 --- a/build-common/src/org/jetbrains/kotlin/modules/KotlinModuleXmlBuilder.kt +++ b/build-common/src/org/jetbrains/kotlin/modules/KotlinModuleXmlBuilder.kt @@ -31,6 +31,7 @@ class KotlinModuleXmlBuilder { openTag(p, MODULES) } + @Deprecated(message = "State of IC should be set explicitly") fun addModule( moduleName: String, outputDir: String, @@ -43,6 +44,34 @@ class KotlinModuleXmlBuilder { isTests: Boolean, directoriesToFilterOut: Set, friendDirs: Iterable + ) = addModule( + moduleName, + outputDir, + sourceFiles, + javaSourceRoots, + classpathRoots, + commonSourceFiles, + modularJdkRoot, + targetTypeId, + isTests, + directoriesToFilterOut, + friendDirs, + IncrementalCompilation.isEnabledForJvm() + ) + + fun addModule( + moduleName: String, + outputDir: String, + sourceFiles: Iterable, + javaSourceRoots: Iterable, + classpathRoots: Iterable, + commonSourceFiles: Iterable, + modularJdkRoot: File?, + targetTypeId: String, + isTests: Boolean, + directoriesToFilterOut: Set, + friendDirs: Iterable, + isIncrementalCompilation: Boolean ): KotlinModuleXmlBuilder { assert(!done) { "Already done" } @@ -67,7 +96,7 @@ class KotlinModuleXmlBuilder { } processJavaSourceRoots(javaSourceRoots) - processClasspath(classpathRoots, directoriesToFilterOut) + processClasspath(classpathRoots, directoriesToFilterOut, isIncrementalCompilation) if (modularJdkRoot != null) { p.println("<", MODULAR_JDK_ROOT, " ", PATH, "=\"", getEscapedPath(modularJdkRoot), "\"/>") @@ -79,10 +108,11 @@ class KotlinModuleXmlBuilder { private fun processClasspath( files: Iterable, - directoriesToFilterOut: Set) { + directoriesToFilterOut: Set, + isIncrementalCompilation: Boolean) { p.println("") for (file in files) { - val isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.isEnabledForJvm() + val isOutput = directoriesToFilterOut.contains(file) && !isIncrementalCompilation if (isOutput) { // For IDEA's make (incremental compilation) purposes, output directories of the current module and its dependencies // appear on the class path, so we are at risk of seeing the results of the previous build, i.e. if some class was diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt index 0338f886ad8..cabe595944e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt @@ -372,7 +372,7 @@ class MultifileClassCodegenImpl( private fun getCompiledPackageFragment( facadeFqName: FqName, state: GenerationState ): IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment? { - if (!IncrementalCompilation.isEnabledForJvm()) return null + if (!state.isIncrementalCompilation) return null val packageFqName = facadeFqName.parent() diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index cbe504ae9b2..b6ff18a6bd4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -72,6 +72,7 @@ class GenerationState private constructor( val isIrBackend: Boolean, val ignoreErrors: Boolean, val diagnosticReporter: DiagnosticReporter, + val isIncrementalCompilation: Boolean ) { class Builder( private val project: Project, @@ -129,13 +130,16 @@ class GenerationState private constructor( fun diagnosticReporter(v: DiagnosticReporter) = apply { diagnosticReporter = v } + val isIncrementalCompilation: Boolean = configuration.getBoolean(CommonConfigurationKeys.INCREMENTAL_COMPILATION) + fun build() = GenerationState( project, builderFactory, module, bindingContext, files, configuration, generateDeclaredClassFilter, codegenFactory, targetId, moduleName, outDirectory, onIndependentPartCompilationEnd, wantsDiagnostics, jvmBackendClassResolver, isIrBackend, ignoreErrors, - diagnosticReporter ?: DiagnosticReporterFactory.createReporter() + diagnosticReporter ?: DiagnosticReporterFactory.createReporter(), + isIncrementalCompilation ) } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 7589ee27dd8..48e507e95a0 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -394,6 +394,9 @@ abstract class CommonCompilerArguments : CommonToolArguments() { ) var normalizeAbsolutePath: Boolean by FreezableVar(false) + @Argument(value = "-Xenable-incremental-compilation", description = "Enable incremental compilation") + var incrementalCompilation: Boolean? by FreezableVar(null) + open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap, Any> { return HashMap, Any>().apply { put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck) diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java index 47db4aeca08..0c87f3c76d8 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java @@ -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 { @@ -181,7 +182,7 @@ public class K2JSCompiler extends CLICompiler { 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 { return ExitCode.COMPILATION_ERROR; } - if (sourcesFiles.isEmpty() && !IncrementalCompilation.isEnabledForJs()) { + if (sourcesFiles.isEmpty() && !incrementalCompilationIsEnabledForJs(arguments)) { messageCollector.report(ERROR, "No source files", null); return COMPILATION_ERROR; } diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index 0fae5c929c4..6d780746d30 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -114,7 +114,7 @@ class K2JsIrCompiler : CLICompiler() { 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() { 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 } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt index 7bc1c2c720f..7384cf33020 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt @@ -27,6 +27,7 @@ fun CompilerConfiguration.setupCommonArguments( put(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER, arguments.expectActualLinker) putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot) put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles) + put(CommonConfigurationKeys.INCREMENTAL_COMPILATION, incrementalCompilationIsEnabled(arguments)) val metadataVersionString = arguments.metadataVersion if (metadataVersionString != null) { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/utils.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/utils.kt index 8e20dc6ab62..c683bf731b9 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/utils.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/utils.kt @@ -16,10 +16,12 @@ package org.jetbrains.kotlin.cli.common +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageUtil import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.config.IncrementalCompilation import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.isSubpackageOf import org.jetbrains.kotlin.psi.KtFile @@ -28,6 +30,14 @@ import org.jetbrains.kotlin.utils.KotlinPaths import java.io.File import kotlin.system.exitProcess +fun incrementalCompilationIsEnabled(arguments: CommonCompilerArguments): Boolean { + return arguments.incrementalCompilation ?: IncrementalCompilation.isEnabledForJvm() +} + +fun incrementalCompilationIsEnabledForJs(arguments: CommonCompilerArguments): Boolean { + return arguments.incrementalCompilation ?: IncrementalCompilation.isEnabledForJs() +} + fun checkKotlinPackageUsage(configuration: CompilerConfiguration, files: Collection): Boolean { if (configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE)) { return true diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 057d7d7607f..c6f1f6c50ac 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -240,7 +240,7 @@ class K2JVMCompiler : CLICompiler() { configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments, services: Services ) { with(configuration) { - if (IncrementalCompilation.isEnabledForJvm()) { + if (incrementalCompilationIsEnabled(arguments)) { putIfNotNull(CommonConfigurationKeys.LOOKUP_TRACKER, services[LookupTracker::class.java]) putIfNotNull(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER, services[ExpectActualTracker::class.java]) diff --git a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt index ed151b8722e..7213245ff0d 100644 --- a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt +++ b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt @@ -66,6 +66,10 @@ object CommonConfigurationKeys { @JvmField val KLIB_NORMALIZE_ABSOLUTE_PATH = CompilerConfigurationKey.create("Normalize absolute paths in klib (replace file separator with '/')") + + @JvmField + val INCREMENTAL_COMPILATION = + CompilerConfigurationKey.create("Enable incremental compilation") } var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt index e94b4cbf3aa..fc481faee3e 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt @@ -319,7 +319,7 @@ abstract class CompileServiceImplBase( CompilerMode.JPS_COMPILER -> { @Suppress("UNCHECKED_CAST") servicesFacade as JpsServicesFacadeT - withIC(enabled = servicesFacade.hasIncrementalCaches()) { + withIC(k2PlatformArgs, enabled = servicesFacade.hasIncrementalCaches()) { doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler -> val services = createServices(servicesFacade, eventManger, profiler) compiler.exec(messageCollector, services, k2PlatformArgs) @@ -346,7 +346,7 @@ abstract class CompileServiceImplBase( val gradleIncrementalServicesFacade = servicesFacade when (targetPlatform) { - CompileService.TargetPlatform.JVM -> withIC { + CompileService.TargetPlatform.JVM -> withIC(k2PlatformArgs) { doCompile(sessionId, daemonReporter, tracer = null) { _, _ -> execIncrementalCompiler( k2PlatformArgs as K2JVMCompilerArguments, @@ -360,7 +360,7 @@ abstract class CompileServiceImplBase( ) } } - CompileService.TargetPlatform.JS -> withJsIC { + CompileService.TargetPlatform.JS -> withJsIC(k2PlatformArgs) { doCompile(sessionId, daemonReporter, tracer = null) { _, _ -> execJsIncrementalCompiler( k2PlatformArgs as K2JSCompilerArguments, diff --git a/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFullPipelineModularizedTest.kt b/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFullPipelineModularizedTest.kt index c7c827c833e..25b33b8f7f6 100644 --- a/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFullPipelineModularizedTest.kt +++ b/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFullPipelineModularizedTest.kt @@ -159,7 +159,8 @@ abstract class AbstractFullPipelineModularizedTest : AbstractModularizedTest() { "java-production", isTests = false, emptySet(), - friendDirs = moduleData.friendDirs + friendDirs = moduleData.friendDirs, + isIncrementalCompilation = true ) val modulesFile = tmp.toFile().resolve("modules.xml") modulesFile.writeText(builder.asText().toString()) diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt index 5d61da8cf5f..6f591ca4f7c 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt @@ -61,7 +61,6 @@ abstract class IncrementalCompilerRunner< //TODO(valtman) temporal measure to ensure quick disable, should be deleted after successful release protected val withSnapshot: Boolean = CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_CLASSPATH_SNAPSHOTS.value.toBooleanLenient() ?: false - protected abstract fun isICEnabled(): Boolean protected abstract fun createCacheManager(args: Args, projectDir: File?): CacheManager protected abstract fun destinationDir(args: Args): File @@ -84,7 +83,6 @@ abstract class IncrementalCompilerRunner< providedChangedFiles: ChangedFiles?, projectDir: File? = null ): ExitCode { - assert(isICEnabled()) { "Incremental compilation is not enabled" } var caches = createCacheManager(args, projectDir) if (withSnapshot) { diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt index 1a40a2efab6..23191780058 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.metrics.BuildAttribute import org.jetbrains.kotlin.build.report.metrics.DoNothingBuildMetricsReporter import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.isIrBackendEnabled import org.jetbrains.kotlin.cli.common.messages.MessageCollector @@ -52,7 +53,7 @@ fun makeJsIncrementally( .filter { it.isFile && it.extension.equals("kt", ignoreCase = true) }.toList() val buildReporter = BuildReporter(icReporter = reporter, buildMetricsReporter = DoNothingBuildMetricsReporter) - withJsIC { + withJsIC(args) { val compiler = IncrementalJsCompilerRunner( cachesDir, buildReporter, buildHistoryFile = buildHistoryFile, @@ -63,11 +64,15 @@ fun makeJsIncrementally( } } -inline fun withJsIC(fn: () -> R): R { +@Suppress("DEPRECATION") +inline fun withJsIC(args: CommonCompilerArguments, enabled: Boolean = true, fn: () -> R): R { val isJsEnabledBackup = IncrementalCompilation.isEnabledForJs() IncrementalCompilation.setIsEnabledForJs(true) try { + if (args.incrementalCompilation == null) { + args.incrementalCompilation = enabled + } return fn() } finally { IncrementalCompilation.setIsEnabledForJs(isJsEnabledBackup) @@ -86,8 +91,6 @@ class IncrementalJsCompilerRunner( reporter, buildHistoryFile = buildHistoryFile ) { - override fun isICEnabled(): Boolean = - IncrementalCompilation.isEnabledForJs() override fun createCacheManager(args: K2JSCompilerArguments, projectDir: File?): IncrementalJsCachesManager { val serializerProtocol = if (!args.isIrBackendEnabled()) JsSerializerProtocol else KlibMetadataSerializerProtocol diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt index be8481be35b..d464d0dc9cb 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.build.report.metrics.DoNothingBuildMetricsReporter import org.jetbrains.kotlin.build.report.metrics.measure import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments import org.jetbrains.kotlin.cli.common.messages.FilteringMessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageCollector @@ -83,7 +84,7 @@ fun makeIncrementally( args.javaSourceRoots = sourceRoots.map { it.absolutePath }.toTypedArray() val buildReporter = BuildReporter(icReporter = reporter, buildMetricsReporter = DoNothingBuildMetricsReporter) - withIC { + withIC(args) { val compiler = IncrementalJvmCompilerRunner( cachesDir, buildReporter, @@ -109,11 +110,15 @@ object EmptyICReporter : ICReporterBase() { override fun reportMarkDirty(affectedFiles: Iterable, reason: String) {} } -inline fun withIC(enabled: Boolean = true, fn: () -> R): R { +@Suppress("DEPRECATION") +inline fun withIC(args: CommonCompilerArguments, enabled: Boolean = true, fn: () -> R): R { val isEnabledBackup = IncrementalCompilation.isEnabledForJvm() IncrementalCompilation.setIsEnabledForJvm(enabled) try { + if (args.incrementalCompilation == null) { + args.incrementalCompilation = enabled + } return fn() } finally { IncrementalCompilation.setIsEnabledForJvm(isEnabledBackup) @@ -136,9 +141,6 @@ class IncrementalJvmCompilerRunner( additionalOutputFiles = outputFiles, buildHistoryFile = buildHistoryFile ) { - override fun isICEnabled(): Boolean = - IncrementalCompilation.isEnabledForJvm() - override fun createCacheManager(args: K2JVMCompilerArguments, projectDir: File?): IncrementalJvmCachesManager = IncrementalJvmCachesManager( cacheDirectory, diff --git a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt index 6038420e7fc..3e1abbcfa00 100644 --- a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt +++ b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt @@ -618,7 +618,7 @@ class ModulesStructure( ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() val analysisResult = analyzer.analysisResult - if (IncrementalCompilation.isEnabledForJs()) { + if (compilerConfiguration.getBoolean(CommonConfigurationKeys.INCREMENTAL_COMPILATION)) { /** can throw [IncrementalNextRoundException] */ compareMetadataAndGoToNextICRoundIfNeeded(analysisResult, compilerConfiguration, project, files, errorPolicy.allowErrors) } diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 4abf26ee045..2ee2a093d71 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -65,6 +65,8 @@ where advanced options include: Use 'warning' level to issue warnings instead of errors. -Xextended-compiler-checks Enable additional compiler checks that might provide verbose diagnostic information for certain errors. Warning: this mode is not backward-compatible and might cause compilation errors in previously compiled code. + -Xenable-incremental-compilation + Enable incremental compilation -Xinference-compatibility Enable compatibility changes for generic type inference algorithm -Xinline-classes Enable experimental inline classes -Xintellij-plugin-root= Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 00b4e90282e..908312afe8a 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -170,6 +170,8 @@ where advanced options include: Use 'warning' level to issue warnings instead of errors. -Xextended-compiler-checks Enable additional compiler checks that might provide verbose diagnostic information for certain errors. Warning: this mode is not backward-compatible and might cause compilation errors in previously compiled code. + -Xenable-incremental-compilation + Enable incremental compilation -Xinference-compatibility Enable compatibility changes for generic type inference algorithm -Xinline-classes Enable experimental inline classes -Xintellij-plugin-root= Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found diff --git a/compiler/util/src/org/jetbrains/kotlin/config/IncrementalCompilation.java b/compiler/util/src/org/jetbrains/kotlin/config/IncrementalCompilation.java index 348871a8937..ea7ecf9225b 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/IncrementalCompilation.java +++ b/compiler/util/src/org/jetbrains/kotlin/config/IncrementalCompilation.java @@ -25,23 +25,26 @@ public class IncrementalCompilation { public static final String INCREMENTAL_COMPILATION_JS_PROPERTY = "kotlin.incremental.compilation.js"; public static boolean isEnabledForJvm() { - return "true".equals(System.getProperty(INCREMENTAL_COMPILATION_JVM_PROPERTY)); + return Boolean.valueOf(System.getProperty(INCREMENTAL_COMPILATION_JVM_PROPERTY)); } public static boolean isEnabledForJs() { - return "true".equals(System.getProperty(INCREMENTAL_COMPILATION_JS_PROPERTY)); + return Boolean.valueOf(System.getProperty(INCREMENTAL_COMPILATION_JS_PROPERTY)); } + @Deprecated @TestOnly public static void setIsEnabledForJvm(boolean value) { System.setProperty(INCREMENTAL_COMPILATION_JVM_PROPERTY, String.valueOf(value)); } + @Deprecated @TestOnly public static void setIsEnabledForJs(boolean value) { System.setProperty(INCREMENTAL_COMPILATION_JS_PROPERTY, String.valueOf(value)); } + @Deprecated public static void toJvmArgs(List jvmArgs) { if (isEnabledForJvm()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_JVM_PROPERTY); if (isEnabledForJs()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_JS_PROPERTY); diff --git a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt index 7e77f28a106..ad452914ae0 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt @@ -319,7 +319,7 @@ class GenerateIrRuntime { val cleanBuildStart = System.nanoTime() - withJsIC { + withJsIC(args) { val buildHistoryFile = File(cachesDir, "build-history.bin") val compiler = IncrementalJsCompilerRunner( cachesDir, BuildReporter(EmptyICReporter, DoNothingBuildMetricsReporter), @@ -363,7 +363,7 @@ class GenerateIrRuntime { done, update ) { - withJsIC { + withJsIC(args) { val buildHistoryFile = File(cachesDir, "build-history.bin") val compiler = IncrementalJsCompilerRunner( cachesDir, BuildReporter(EmptyICReporter, DoNothingBuildMetricsReporter),