Enable disabling incremental compilation for tests

This commit is contained in:
Alexey Tsvetkov
2015-09-24 23:26:53 +03:00
parent b6bbc4015b
commit 68437175f6
8 changed files with 30 additions and 14 deletions
@@ -247,7 +247,7 @@ public class MultifileClassCodegen(
}
private fun getCompiledPackageFragment(packageFqName: FqName, state: GenerationState): PackageFragmentDescriptor? =
if (!IncrementalCompilation.ENABLED) null
if (!IncrementalCompilation.isEnabled()) null
else state.module.getPackage(packageFqName).fragments.firstOrNull { fragment ->
fragment is IncrementalPackageFragmentProvider.IncrementalPackageFragment &&
fragment.target == state.targetId
@@ -141,7 +141,7 @@ public class PackageCodegen {
@Nullable
private PackageFragmentDescriptor getCompiledPackageFragment(@NotNull FqName fqName) {
if (!IncrementalCompilation.ENABLED) {
if (!IncrementalCompilation.isEnabled()) {
return null;
}
@@ -65,7 +65,7 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
val configuration = CompilerConfiguration()
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageSeverityCollector)
if (IncrementalCompilation.ENABLED) {
if (IncrementalCompilation.isEnabled()) {
val incrementalCompilationComponents = services.get(javaClass<IncrementalCompilationComponents>())
configuration.put(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS, incrementalCompilationComponents)
}
@@ -16,6 +16,22 @@
package org.jetbrains.kotlin.config;
import org.jetbrains.annotations.TestOnly;
public class IncrementalCompilation {
public static final boolean ENABLED = !"false".equals(System.getProperty("kotlin.incremental.compilation"));
}
private static final String INCREMENTAL_COMPILATION_PROPERTY = "kotlin.incremental.compilation";
public static boolean isEnabled() {
return !"false".equals(System.getProperty(INCREMENTAL_COMPILATION_PROPERTY));
}
@TestOnly
public static void disableIncrementalCompilation() {
System.setProperty(INCREMENTAL_COMPILATION_PROPERTY, "false");
}
@TestOnly
public static void enableIncrementalCompilation() {
System.setProperty(INCREMENTAL_COMPILATION_PROPERTY, "true");
}
}
@@ -134,7 +134,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val dataManager = projectDescriptor.dataManager
if (IncrementalCompilation.ENABLED &&
if (IncrementalCompilation.isEnabled() &&
chunk.targets.any { dataManager.dataPaths.getKotlinCacheVersion(it).isIncompatible() }
) {
LOG.info("Clearing caches for " + chunk.targets.map { it.presentableName }.join())
@@ -215,7 +215,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
copyJsLibraryFilesIfNeeded(chunk, project)
}
if (!IncrementalCompilation.ENABLED) return OK
if (!IncrementalCompilation.isEnabled()) return OK
val caches = filesToCompile.keySet().map { incrementalCaches[it]!! }
val marker = ChangesProcessor(context, chunk, allCompiledFiles, caches)
@@ -293,8 +293,8 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
return compileToJs(chunk, commonArguments, environment, null, messageCollector, project)
}
if (IncrementalCompilation.ENABLED) {
for (target in chunk.getTargets()) {
if (IncrementalCompilation.isEnabled()) {
for (target in chunk.targets) {
val cache = incrementalCaches[target]!!
val removedAndDirtyFiles = filesToCompile[target] + dirtyFilesHolder.getRemovedFiles(target).map { File(it) }
cache.markOutputClassesDirty(removedAndDirtyFiles)
@@ -410,7 +410,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
return sources
}
if (!IncrementalCompilation.ENABLED) {
if (!IncrementalCompilation.isEnabled()) {
return
}
@@ -449,7 +449,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
): ChangesInfo {
incrementalCaches.values().forEach { it.saveCacheFormatVersion() }
if (!IncrementalCompilation.ENABLED) {
if (!IncrementalCompilation.isEnabled()) {
return ChangesInfo.NO_CHANGES
}
@@ -72,7 +72,7 @@ public class KotlinBuilderModuleScriptGenerator {
File outputDir = getOutputDirSafe(target);
List<File> moduleSources = new ArrayList<File>(
IncrementalCompilation.ENABLED
IncrementalCompilation.isEnabled()
? sourceFiles.get(target)
: KotlinSourceFileCollector.getAllKotlinSourceFiles(target));
@@ -38,7 +38,7 @@ class CacheFormatVersion(targetDataRoot: File) {
private val file = File(targetDataRoot, FORMAT_VERSION_FILE_PATH)
fun isIncompatible(): Boolean {
assert(IncrementalCompilation.ENABLED) { "Incremental compilation is not enabled" }
assert(IncrementalCompilation.isEnabled()) { "Incremental compilation is not enabled" }
if (!file.exists()) return false
val versionNumber = file.readText().toInt()
@@ -83,7 +83,7 @@ public class KotlinModuleXmlBuilder {
) {
p.println("<!-- Classpath -->");
for (File file : files) {
boolean isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.ENABLED;
boolean isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.isEnabled();
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