Fix caches closing/flushing when IC builds non-incrementally
This commit is contained in:
+26
-20
@@ -26,20 +26,26 @@ internal class IncrementalCachesManager (
|
||||
) {
|
||||
private val incrementalCacheDir = File(cacheDirectory, "increCache.${targetId.name}")
|
||||
private val lookupCacheDir = File(cacheDirectory, "lookups")
|
||||
private var incrementalCacheOpen = false
|
||||
private var lookupCacheOpen = false
|
||||
private var incrementalCacheField: GradleIncrementalCacheImpl? = null
|
||||
private var lookupCacheField: LookupStorage? = null
|
||||
|
||||
val incrementalCache: GradleIncrementalCacheImpl by lazy {
|
||||
val cache = GradleIncrementalCacheImpl(targetDataRoot = incrementalCacheDir.apply { mkdirs() }, targetOutputDir = outputDir, target = targetId)
|
||||
incrementalCacheOpen = true
|
||||
cache
|
||||
}
|
||||
val incrementalCache: GradleIncrementalCacheImpl
|
||||
get() {
|
||||
if (incrementalCacheField == null) {
|
||||
incrementalCacheField = GradleIncrementalCacheImpl(targetDataRoot = incrementalCacheDir.apply { mkdirs() }, targetOutputDir = outputDir, target = targetId)
|
||||
}
|
||||
|
||||
val lookupCache: LookupStorage by lazy {
|
||||
val cache = LookupStorage(lookupCacheDir.apply { mkdirs() })
|
||||
lookupCacheOpen = true
|
||||
cache
|
||||
}
|
||||
return incrementalCacheField!!
|
||||
}
|
||||
|
||||
val lookupCache: LookupStorage
|
||||
get() {
|
||||
if (lookupCacheField == null) {
|
||||
lookupCacheField = LookupStorage(lookupCacheDir.apply { mkdirs() })
|
||||
}
|
||||
|
||||
return lookupCacheField!!
|
||||
}
|
||||
|
||||
fun clean() {
|
||||
close(flush = false)
|
||||
@@ -47,20 +53,20 @@ internal class IncrementalCachesManager (
|
||||
}
|
||||
|
||||
fun close(flush: Boolean = false) {
|
||||
if (incrementalCacheOpen) {
|
||||
incrementalCacheField?.let {
|
||||
if (flush) {
|
||||
incrementalCache.flush(false)
|
||||
it.flush(false)
|
||||
}
|
||||
incrementalCache.close()
|
||||
incrementalCacheOpen = false
|
||||
it.close()
|
||||
incrementalCacheField = null
|
||||
}
|
||||
|
||||
if (lookupCacheOpen) {
|
||||
lookupCacheField?.let {
|
||||
if (flush) {
|
||||
lookupCache.flush(false)
|
||||
it.flush(false)
|
||||
}
|
||||
lookupCache.close()
|
||||
lookupCacheOpen = false
|
||||
it.close()
|
||||
lookupCacheField = null
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -132,7 +132,7 @@ internal class IncrementalJvmCompilerRunner(
|
||||
return try {
|
||||
val javaFilesProcessor = ChangedJavaFilesProcessor()
|
||||
val changedFiles = getChangedFiles(caches)
|
||||
val compilationMode = calculateSourcesToCompile(javaFilesProcessor, caches, changedFiles, args.classpathAsList)
|
||||
val compilationMode = calculateSourcesToCompile(javaFilesProcessor, caches, changedFiles, args)
|
||||
compileIncrementally(args, caches, javaFilesProcessor, allKotlinSources, targetId, compilationMode, messageCollector)
|
||||
}
|
||||
catch (e: PersistentEnumeratorBase.CorruptedException) {
|
||||
@@ -161,12 +161,13 @@ internal class IncrementalJvmCompilerRunner(
|
||||
javaFilesProcessor: ChangedJavaFilesProcessor,
|
||||
caches: IncrementalCachesManager,
|
||||
changedFiles: ChangedFiles,
|
||||
classpath: Iterable<File>
|
||||
args: K2JVMCompilerArguments
|
||||
): CompilationMode {
|
||||
fun rebuild(reason: ()->String): CompilationMode {
|
||||
reporter.report {"Non-incremental compilation will be performed: ${reason()}"}
|
||||
caches.clean()
|
||||
dirtySourcesSinceLastTimeFile.delete()
|
||||
args.destinationAsFile.deleteRecursively()
|
||||
return CompilationMode.Rebuild
|
||||
}
|
||||
|
||||
@@ -178,7 +179,7 @@ internal class IncrementalJvmCompilerRunner(
|
||||
val modifiedClassFiles = changedFiles.modified.filter(File::isClassFile)
|
||||
if (modifiedClassFiles.any()) return rebuild {"Modified class files: ${reporter.pathsAsString(modifiedClassFiles)}"}
|
||||
|
||||
val classpathSet = classpath.toHashSet()
|
||||
val classpathSet = args.classpathAsList.toHashSet()
|
||||
val modifiedClasspathEntries = changedFiles.modified.filter {it in classpathSet}
|
||||
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile)
|
||||
reporter.report { "Last Kotlin Build info -- $lastBuildInfo" }
|
||||
|
||||
Reference in New Issue
Block a user