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