Fix unstable testIncrementalCompilationAfterCacheHit test
This commit is contained in:
+13
-13
@@ -49,18 +49,16 @@ abstract class IncrementalCompilerRunner<
|
||||
protected val buildHistoryFile: File,
|
||||
// there might be some additional output directories (e.g. for generated java in kapt)
|
||||
// to remove them correctly on rebuild, we pass them as additional argument
|
||||
private val additionalOutputFiles: Collection<File> = emptyList()
|
||||
private val additionalOutputFiles: Collection<File> = emptyList(),
|
||||
protected val withAbiSnapshot: Boolean = false
|
||||
) {
|
||||
|
||||
protected val cacheDirectory = File(workingDir, cacheDirName)
|
||||
private val dirtySourcesSinceLastTimeFile = File(workingDir, DIRTY_SOURCES_FILE_NAME)
|
||||
protected val lastBuildInfoFile = File(workingDir, LAST_BUILD_INFO_FILE_NAME)
|
||||
protected val abiSnapshotFile = File(workingDir, ABI_SNAPSHOT_FILE_NAME)
|
||||
private val abiSnapshotFile = File(workingDir, ABI_SNAPSHOT_FILE_NAME)
|
||||
protected open val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
|
||||
|
||||
//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 createCacheManager(args: Args, projectDir: File?): CacheManager
|
||||
protected abstract fun destinationDir(args: Args): File
|
||||
|
||||
@@ -85,14 +83,14 @@ abstract class IncrementalCompilerRunner<
|
||||
): ExitCode {
|
||||
var caches = createCacheManager(args, projectDir)
|
||||
|
||||
if (withSnapshot) {
|
||||
if (withAbiSnapshot) {
|
||||
reporter.report { "Incremental compilation with ABI snapshot enabled" }
|
||||
}
|
||||
//TODO if abi-snapshot is corrupted unable to rebuild. Should roll back to withSnapshot = false?
|
||||
val classpathAbiSnapshot =
|
||||
if (withSnapshot) {
|
||||
if (withAbiSnapshot) {
|
||||
reporter.measure(BuildTime.SET_UP_ABI_SNAPSHOTS) {
|
||||
setupJarDependencies(args, withSnapshot, reporter)
|
||||
setupJarDependencies(args, withAbiSnapshot, reporter)
|
||||
}
|
||||
} else {
|
||||
emptyMap()
|
||||
@@ -110,8 +108,10 @@ abstract class IncrementalCompilerRunner<
|
||||
caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allSourceFiles)
|
||||
}
|
||||
val allKotlinFiles = allSourceFiles.filter { it.isKotlinFile(kotlinSourceFilesExtensions) }
|
||||
return compileIncrementally(args, caches, allKotlinFiles, CompilationMode.Rebuild(reason), messageCollector, withSnapshot,
|
||||
classpathAbiSnapshot = classpathAbiSnapshot)
|
||||
return compileIncrementally(
|
||||
args, caches, allKotlinFiles, CompilationMode.Rebuild(reason), messageCollector, withAbiSnapshot,
|
||||
classpathAbiSnapshot = classpathAbiSnapshot
|
||||
)
|
||||
}
|
||||
|
||||
// If compilation has crashed or we failed to close caches we have to clear them
|
||||
@@ -134,7 +134,7 @@ abstract class IncrementalCompilerRunner<
|
||||
|
||||
val exitCode = when (compilationMode) {
|
||||
is CompilationMode.Incremental -> {
|
||||
if (withSnapshot) {
|
||||
if (withAbiSnapshot) {
|
||||
val abiSnapshot = AbiSnapshotImpl.read(abiSnapshotFile, reporter)
|
||||
if (abiSnapshot != null) {
|
||||
compileIncrementally(
|
||||
@@ -143,7 +143,7 @@ abstract class IncrementalCompilerRunner<
|
||||
allSourceFiles,
|
||||
compilationMode,
|
||||
messageCollector,
|
||||
withSnapshot,
|
||||
withAbiSnapshot,
|
||||
abiSnapshot,
|
||||
classpathAbiSnapshot
|
||||
)
|
||||
@@ -157,7 +157,7 @@ abstract class IncrementalCompilerRunner<
|
||||
allSourceFiles,
|
||||
compilationMode,
|
||||
messageCollector,
|
||||
withSnapshot
|
||||
withAbiSnapshot
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -84,12 +84,14 @@ class IncrementalJsCompilerRunner(
|
||||
reporter: BuildReporter,
|
||||
buildHistoryFile: File,
|
||||
private val modulesApiHistory: ModulesApiHistory,
|
||||
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER
|
||||
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
|
||||
withAbiSnapshot: Boolean = false
|
||||
) : IncrementalCompilerRunner<K2JSCompilerArguments, IncrementalJsCachesManager>(
|
||||
workingDir,
|
||||
"caches-js",
|
||||
reporter,
|
||||
buildHistoryFile = buildHistoryFile
|
||||
buildHistoryFile = buildHistoryFile,
|
||||
withAbiSnapshot = withAbiSnapshot
|
||||
) {
|
||||
|
||||
override fun createCacheManager(args: K2JSCompilerArguments, projectDir: File?): IncrementalJsCachesManager {
|
||||
@@ -99,7 +101,7 @@ class IncrementalJsCompilerRunner(
|
||||
projectDir,
|
||||
reporter,
|
||||
serializerProtocol,
|
||||
storeFullFqNamesInLookupCache = withSnapshot
|
||||
storeFullFqNamesInLookupCache = withAbiSnapshot
|
||||
)
|
||||
}
|
||||
|
||||
@@ -118,7 +120,7 @@ class IncrementalJsCompilerRunner(
|
||||
messageCollector: MessageCollector,
|
||||
classpathAbiSnapshots: Map<String, AbiSnapshot> //Ignore for now
|
||||
): CompilationMode {
|
||||
if (!withSnapshot && !buildHistoryFile.isFile) {
|
||||
if (!withAbiSnapshot && !buildHistoryFile.isFile) {
|
||||
return CompilationMode.Rebuild(BuildAttribute.NO_BUILD_HISTORY)
|
||||
}
|
||||
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile)
|
||||
|
||||
+10
-8
@@ -98,7 +98,6 @@ fun makeIncrementally(
|
||||
kotlinSourceFilesExtensions = kotlinExtensions,
|
||||
classpathChanges = ClasspathSnapshotDisabled
|
||||
)
|
||||
//TODO set properly
|
||||
compiler.compile(sourceFiles, args, messageCollector, providedChangedFiles = null)
|
||||
}
|
||||
}
|
||||
@@ -135,13 +134,15 @@ class IncrementalJvmCompilerRunner(
|
||||
outputFiles: Collection<File>,
|
||||
private val modulesApiHistory: ModulesApiHistory,
|
||||
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
|
||||
private val classpathChanges: ClasspathChanges
|
||||
private val classpathChanges: ClasspathChanges,
|
||||
withAbiSnapshot: Boolean = false
|
||||
) : IncrementalCompilerRunner<K2JVMCompilerArguments, IncrementalJvmCachesManager>(
|
||||
workingDir,
|
||||
"caches-jvm",
|
||||
reporter,
|
||||
additionalOutputFiles = outputFiles,
|
||||
buildHistoryFile = buildHistoryFile
|
||||
buildHistoryFile = buildHistoryFile,
|
||||
withAbiSnapshot = withAbiSnapshot
|
||||
) {
|
||||
override fun createCacheManager(args: K2JVMCompilerArguments, projectDir: File?): IncrementalJvmCachesManager =
|
||||
IncrementalJvmCachesManager(
|
||||
@@ -149,7 +150,7 @@ class IncrementalJvmCompilerRunner(
|
||||
projectDir,
|
||||
File(args.destination),
|
||||
reporter,
|
||||
storeFullFqNamesInLookupCache = withSnapshot || classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled,
|
||||
storeFullFqNamesInLookupCache = withAbiSnapshot || classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled,
|
||||
trackChangesInLookupCache = classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled.IncrementalRun
|
||||
)
|
||||
|
||||
@@ -191,7 +192,7 @@ class IncrementalJvmCompilerRunner(
|
||||
classpathAbiSnapshots: Map<String, AbiSnapshot>
|
||||
): CompilationMode {
|
||||
return try {
|
||||
calculateSourcesToCompileImpl(caches, changedFiles, args, classpathAbiSnapshots)
|
||||
calculateSourcesToCompileImpl(caches, changedFiles, args, classpathAbiSnapshots, withAbiSnapshot)
|
||||
} finally {
|
||||
psiFileProvider.messageCollector.flush(messageCollector)
|
||||
psiFileProvider.messageCollector.clear()
|
||||
@@ -228,7 +229,8 @@ class IncrementalJvmCompilerRunner(
|
||||
caches: IncrementalJvmCachesManager,
|
||||
changedFiles: ChangedFiles.Known,
|
||||
args: K2JVMCompilerArguments,
|
||||
abiSnapshots: Map<String, AbiSnapshot> = HashMap()
|
||||
abiSnapshots: Map<String, AbiSnapshot> = HashMap(),
|
||||
withAbiSnapshot: Boolean
|
||||
): CompilationMode {
|
||||
val dirtyFiles = DirtyFilesContainer(caches, reporter, kotlinSourceFilesExtensions)
|
||||
initDirtyFiles(dirtyFiles, changedFiles)
|
||||
@@ -264,7 +266,7 @@ class IncrementalJvmCompilerRunner(
|
||||
is NotAvailableDueToMissingClasspathSnapshot -> ChangesEither.Unknown(BuildAttribute.CLASSPATH_SNAPSHOT_NOT_FOUND)
|
||||
is NotAvailableForNonIncrementalRun -> ChangesEither.Unknown(BuildAttribute.UNKNOWN_CHANGES_IN_GRADLE_INPUTS)
|
||||
is ClasspathSnapshotDisabled -> reporter.measure(BuildTime.IC_ANALYZE_CHANGES_IN_DEPENDENCIES) {
|
||||
if (!withSnapshot && !buildHistoryFile.isFile) {
|
||||
if (!withAbiSnapshot && !buildHistoryFile.isFile) {
|
||||
// If the previous build was a Gradle cache hit, the build history file must have been deleted as it is marked as
|
||||
// @LocalState in the Gradle task. Therefore, this compilation will need to run non-incrementally.
|
||||
// (Note that buildHistoryFile is outside workingDir. We don't need to perform the same check for files inside
|
||||
@@ -276,7 +278,7 @@ class IncrementalJvmCompilerRunner(
|
||||
val scopes = caches.lookupCache.lookupSymbols.map { it.scope.ifBlank { it.name } }.distinct()
|
||||
|
||||
getClasspathChanges(
|
||||
args.classpathAsList, changedFiles, lastBuildInfo, modulesApiHistory, reporter, abiSnapshots, withSnapshot,
|
||||
args.classpathAsList, changedFiles, lastBuildInfo, modulesApiHistory, reporter, abiSnapshots, withAbiSnapshot,
|
||||
caches.platformCache, scopes
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user