Format and cleanup incremental-compilation-impl
This commit is contained in:
+3
-5
@@ -55,8 +55,7 @@ data class BuildDiffsStorage(val buildDiffs: List<BuildDifference>) {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
} catch (e: IOException) {
|
||||||
catch (e: IOException) {
|
|
||||||
reportFail(e.toString())
|
reportFail(e.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +75,7 @@ data class BuildDiffsStorage(val buildDiffs: List<BuildDifference>) {
|
|||||||
output.writeBuildDifference(diff)
|
output.writeBuildDifference(diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (e: IOException) {
|
||||||
catch (e: IOException) {
|
|
||||||
reporter?.report { "Could not write diff to file $file: $e" }
|
reporter?.report { "Could not write diff to file $file: $e" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,7 +127,7 @@ data class BuildDiffsStorage(val buildDiffs: List<BuildDifference>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val MAX_DIFFS_ENTRIES: Int = 10
|
internal const val MAX_DIFFS_ENTRIES: Int = 10
|
||||||
|
|
||||||
@set:TestOnly
|
@set:TestOnly
|
||||||
var CURRENT_VERSION: Int = 0
|
var CURRENT_VERSION: Int = 0
|
||||||
|
|||||||
+6
-7
@@ -21,14 +21,13 @@ import java.io.*
|
|||||||
data class BuildInfo(val startTS: Long) : Serializable {
|
data class BuildInfo(val startTS: Long) : Serializable {
|
||||||
companion object {
|
companion object {
|
||||||
fun read(file: File): BuildInfo? =
|
fun read(file: File): BuildInfo? =
|
||||||
try {
|
try {
|
||||||
ObjectInputStream(FileInputStream(file)).use {
|
ObjectInputStream(FileInputStream(file)).use {
|
||||||
it.readObject() as BuildInfo
|
it.readObject() as BuildInfo
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e: Exception) {
|
|
||||||
null
|
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
fun write(buildInfo: BuildInfo, file: File) {
|
fun write(buildInfo: BuildInfo, file: File) {
|
||||||
ObjectOutputStream(FileOutputStream(file)).use {
|
ObjectOutputStream(FileOutputStream(file)).use {
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@ import java.io.File
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
internal class ChangedJavaFilesProcessor(
|
internal class ChangedJavaFilesProcessor(
|
||||||
private val reporter: ICReporter,
|
private val reporter: ICReporter,
|
||||||
private val psiFileFactory: (File) -> PsiFile?
|
private val psiFileFactory: (File) -> PsiFile?
|
||||||
) {
|
) {
|
||||||
private val allSymbols = HashSet<LookupSymbol>()
|
private val allSymbols = HashSet<LookupSymbol>()
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -20,8 +20,9 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
|
|
||||||
internal sealed class ChangesEither {
|
internal sealed class ChangesEither {
|
||||||
internal class Known(
|
internal class Known(
|
||||||
val lookupSymbols: Collection<LookupSymbol> = emptyList(),
|
val lookupSymbols: Collection<LookupSymbol> = emptyList(),
|
||||||
val fqNames: Collection<FqName> = emptyList()
|
val fqNames: Collection<FqName> = emptyList()
|
||||||
) : ChangesEither()
|
) : ChangesEither()
|
||||||
|
|
||||||
internal class Unknown(val reason: String? = null) : ChangesEither()
|
internal class Unknown(val reason: String? = null) : ChangesEither()
|
||||||
}
|
}
|
||||||
+45
-39
@@ -35,9 +35,9 @@ import java.io.File
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
abstract class IncrementalCompilerRunner<
|
abstract class IncrementalCompilerRunner<
|
||||||
Args : CommonCompilerArguments,
|
Args : CommonCompilerArguments,
|
||||||
CacheManager : IncrementalCachesManager<*>
|
CacheManager : IncrementalCachesManager<*>
|
||||||
>(
|
>(
|
||||||
private val workingDir: File,
|
private val workingDir: File,
|
||||||
cacheDirName: String,
|
cacheDirName: String,
|
||||||
protected val reporter: ICReporter,
|
protected val reporter: ICReporter,
|
||||||
@@ -48,7 +48,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
protected val cacheDirectory = File(workingDir, cacheDirName)
|
protected val cacheDirectory = File(workingDir, cacheDirName)
|
||||||
protected val dirtySourcesSinceLastTimeFile = File(workingDir, DIRTY_SOURCES_FILE_NAME)
|
private val dirtySourcesSinceLastTimeFile = File(workingDir, DIRTY_SOURCES_FILE_NAME)
|
||||||
protected val lastBuildInfoFile = File(workingDir, LAST_BUILD_INFO_FILE_NAME)
|
protected val lastBuildInfoFile = File(workingDir, LAST_BUILD_INFO_FILE_NAME)
|
||||||
protected open val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
|
protected open val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
|
||||||
|
|
||||||
@@ -57,12 +57,12 @@ abstract class IncrementalCompilerRunner<
|
|||||||
protected abstract fun destinationDir(args: Args): File
|
protected abstract fun destinationDir(args: Args): File
|
||||||
|
|
||||||
fun compile(
|
fun compile(
|
||||||
allSourceFiles: List<File>,
|
allSourceFiles: List<File>,
|
||||||
args: Args,
|
args: Args,
|
||||||
messageCollector: MessageCollector,
|
messageCollector: MessageCollector,
|
||||||
// when [providedChangedFiles] is not null, changes are provided by external system (e.g. Gradle)
|
// when [providedChangedFiles] is not null, changes are provided by external system (e.g. Gradle)
|
||||||
// otherwise we track source files changes ourselves.
|
// otherwise we track source files changes ourselves.
|
||||||
providedChangedFiles: ChangedFiles?
|
providedChangedFiles: ChangedFiles?
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
assert(isICEnabled()) { "Incremental compilation is not enabled" }
|
assert(isICEnabled()) { "Incremental compilation is not enabled" }
|
||||||
var caches = createCacheManager(args)
|
var caches = createCacheManager(args)
|
||||||
@@ -95,8 +95,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
if (!caches.close(flush = true)) throw RuntimeException("Could not flush caches")
|
if (!caches.close(flush = true)) throw RuntimeException("Could not flush caches")
|
||||||
|
|
||||||
return exitCode
|
return exitCode
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception) {
|
|
||||||
// todo: warn?
|
// todo: warn?
|
||||||
rebuild { "Possible cache corruption. Rebuilding. $e" }
|
rebuild { "Possible cache corruption. Rebuilding. $e" }
|
||||||
}
|
}
|
||||||
@@ -131,10 +130,10 @@ abstract class IncrementalCompilerRunner<
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun sourcesToCompile(caches: CacheManager, changedFiles: ChangedFiles, args: Args): CompilationMode =
|
private fun sourcesToCompile(caches: CacheManager, changedFiles: ChangedFiles, args: Args): CompilationMode =
|
||||||
when (changedFiles) {
|
when (changedFiles) {
|
||||||
is ChangedFiles.Known -> calculateSourcesToCompile(caches, changedFiles, args)
|
is ChangedFiles.Known -> calculateSourcesToCompile(caches, changedFiles, args)
|
||||||
is ChangedFiles.Unknown -> CompilationMode.Rebuild { "inputs' changes are unknown (first or clean build)" }
|
is ChangedFiles.Unknown -> CompilationMode.Rebuild { "inputs' changes are unknown (first or clean build)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun calculateSourcesToCompile(caches: CacheManager, changedFiles: ChangedFiles.Known, args: Args): CompilationMode
|
protected abstract fun calculateSourcesToCompile(caches: CacheManager, changedFiles: ChangedFiles.Known, args: Args): CompilationMode
|
||||||
|
|
||||||
@@ -156,26 +155,26 @@ abstract class IncrementalCompilerRunner<
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun updateCaches(
|
protected abstract fun updateCaches(
|
||||||
services: Services,
|
services: Services,
|
||||||
caches: CacheManager,
|
caches: CacheManager,
|
||||||
generatedFiles: List<GeneratedFile>,
|
generatedFiles: List<GeneratedFile>,
|
||||||
changesCollector: ChangesCollector
|
changesCollector: ChangesCollector
|
||||||
)
|
)
|
||||||
|
|
||||||
protected open fun preBuildHook(args: Args, compilationMode: CompilationMode) {}
|
protected open fun preBuildHook(args: Args, compilationMode: CompilationMode) {}
|
||||||
protected open fun postCompilationHook(exitCode: ExitCode) {}
|
protected open fun postCompilationHook(exitCode: ExitCode) {}
|
||||||
protected open fun additionalDirtyFiles(caches: CacheManager, generatedFiles: List<GeneratedFile>): Iterable<File> =
|
protected open fun additionalDirtyFiles(caches: CacheManager, generatedFiles: List<GeneratedFile>): Iterable<File> =
|
||||||
emptyList()
|
emptyList()
|
||||||
|
|
||||||
protected open fun additionalDirtyLookupSymbols(): Iterable<LookupSymbol> =
|
protected open fun additionalDirtyLookupSymbols(): Iterable<LookupSymbol> =
|
||||||
emptyList()
|
emptyList()
|
||||||
|
|
||||||
protected open fun makeServices(
|
protected open fun makeServices(
|
||||||
args: Args,
|
args: Args,
|
||||||
lookupTracker: LookupTracker,
|
lookupTracker: LookupTracker,
|
||||||
expectActualTracker: ExpectActualTracker,
|
expectActualTracker: ExpectActualTracker,
|
||||||
caches: CacheManager,
|
caches: CacheManager,
|
||||||
compilationMode: CompilationMode
|
compilationMode: CompilationMode
|
||||||
): Services.Builder =
|
): Services.Builder =
|
||||||
Services.Builder().apply {
|
Services.Builder().apply {
|
||||||
register(LookupTracker::class.java, lookupTracker)
|
register(LookupTracker::class.java, lookupTracker)
|
||||||
@@ -184,19 +183,19 @@ abstract class IncrementalCompilerRunner<
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun runCompiler(
|
protected abstract fun runCompiler(
|
||||||
sourcesToCompile: Set<File>,
|
sourcesToCompile: Set<File>,
|
||||||
args: Args,
|
args: Args,
|
||||||
caches: CacheManager,
|
caches: CacheManager,
|
||||||
services: Services,
|
services: Services,
|
||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
): ExitCode
|
): ExitCode
|
||||||
|
|
||||||
private fun compileIncrementally(
|
private fun compileIncrementally(
|
||||||
args: Args,
|
args: Args,
|
||||||
caches: CacheManager,
|
caches: CacheManager,
|
||||||
allKotlinSources: List<File>,
|
allKotlinSources: List<File>,
|
||||||
compilationMode: CompilationMode,
|
compilationMode: CompilationMode,
|
||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
preBuildHook(args, compilationMode)
|
preBuildHook(args, compilationMode)
|
||||||
|
|
||||||
@@ -264,10 +263,17 @@ abstract class IncrementalCompilerRunner<
|
|||||||
val (dirtyLookupSymbols, dirtyClassFqNames) = changesCollector.getDirtyData(listOf(caches.platformCache), reporter)
|
val (dirtyLookupSymbols, dirtyClassFqNames) = changesCollector.getDirtyData(listOf(caches.platformCache), reporter)
|
||||||
val compiledInThisIterationSet = sourcesToCompile.toHashSet()
|
val compiledInThisIterationSet = sourcesToCompile.toHashSet()
|
||||||
|
|
||||||
with (dirtySources) {
|
with(dirtySources) {
|
||||||
clear()
|
clear()
|
||||||
addAll(mapLookupSymbolsToFiles(caches.lookupCache, dirtyLookupSymbols, reporter, excludes = compiledInThisIterationSet))
|
addAll(mapLookupSymbolsToFiles(caches.lookupCache, dirtyLookupSymbols, reporter, excludes = compiledInThisIterationSet))
|
||||||
addAll(mapClassesFqNamesToFiles(listOf(caches.platformCache), dirtyClassFqNames, reporter, excludes = compiledInThisIterationSet))
|
addAll(
|
||||||
|
mapClassesFqNamesToFiles(
|
||||||
|
listOf(caches.platformCache),
|
||||||
|
dirtyClassFqNames,
|
||||||
|
reporter,
|
||||||
|
excludes = compiledInThisIterationSet
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
buildDirtyLookupSymbols.addAll(dirtyLookupSymbols)
|
buildDirtyLookupSymbols.addAll(dirtyLookupSymbols)
|
||||||
|
|||||||
+5
-2
@@ -26,7 +26,10 @@ import org.jetbrains.kotlin.config.IncrementalCompilation
|
|||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.incremental.js.*
|
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
||||||
|
import org.jetbrains.kotlin.incremental.js.IncrementalDataProviderFromCache
|
||||||
|
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||||
|
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
|
||||||
import org.jetbrains.kotlin.incremental.multiproject.EmptyModulesApiHistory
|
import org.jetbrains.kotlin.incremental.multiproject.EmptyModulesApiHistory
|
||||||
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistory
|
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistory
|
||||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
|
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
|
||||||
@@ -145,7 +148,7 @@ class IncrementalJsCompilerRunner(
|
|||||||
generatedFiles: List<GeneratedFile>,
|
generatedFiles: List<GeneratedFile>,
|
||||||
changesCollector: ChangesCollector
|
changesCollector: ChangesCollector
|
||||||
) {
|
) {
|
||||||
val incrementalResults = services.get(IncrementalResultsConsumer::class.java) as IncrementalResultsConsumerImpl
|
val incrementalResults = services[IncrementalResultsConsumer::class.java] as IncrementalResultsConsumerImpl
|
||||||
|
|
||||||
val jsCache = caches.platformCache
|
val jsCache = caches.platformCache
|
||||||
jsCache.header = incrementalResults.headerMetadata
|
jsCache.header = incrementalResults.headerMetadata
|
||||||
|
|||||||
+43
-42
@@ -25,7 +25,6 @@ import com.intellij.psi.PsiJavaFile
|
|||||||
import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
|
import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
|
||||||
import org.jetbrains.kotlin.build.GeneratedFile
|
import org.jetbrains.kotlin.build.GeneratedFile
|
||||||
import org.jetbrains.kotlin.build.GeneratedJvmClass
|
import org.jetbrains.kotlin.build.GeneratedJvmClass
|
||||||
import org.jetbrains.kotlin.build.JvmSourceRoot
|
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
@@ -47,14 +46,13 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.ObjectOutputStream
|
|
||||||
|
|
||||||
fun makeIncrementally(
|
fun makeIncrementally(
|
||||||
cachesDir: File,
|
cachesDir: File,
|
||||||
sourceRoots: Iterable<File>,
|
sourceRoots: Iterable<File>,
|
||||||
args: K2JVMCompilerArguments,
|
args: K2JVMCompilerArguments,
|
||||||
messageCollector: MessageCollector = MessageCollector.NONE,
|
messageCollector: MessageCollector = MessageCollector.NONE,
|
||||||
reporter: ICReporter = EmptyICReporter
|
reporter: ICReporter = EmptyICReporter
|
||||||
) {
|
) {
|
||||||
val kotlinExtensions = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
|
val kotlinExtensions = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
|
||||||
val allExtensions = kotlinExtensions + "java"
|
val allExtensions = kotlinExtensions + "java"
|
||||||
@@ -90,14 +88,13 @@ object EmptyICReporter : ICReporterBase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <R> withIC(enabled: Boolean = true, fn: ()->R): R {
|
inline fun <R> withIC(enabled: Boolean = true, fn: () -> R): R {
|
||||||
val isEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
val isEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
||||||
IncrementalCompilation.setIsEnabledForJvm(enabled)
|
IncrementalCompilation.setIsEnabledForJvm(enabled)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return fn()
|
return fn()
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
IncrementalCompilation.setIsEnabledForJvm(isEnabledBackup)
|
IncrementalCompilation.setIsEnabledForJvm(isEnabledBackup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,15 +115,15 @@ class IncrementalJvmCompilerRunner(
|
|||||||
buildHistoryFile = buildHistoryFile
|
buildHistoryFile = buildHistoryFile
|
||||||
) {
|
) {
|
||||||
override fun isICEnabled(): Boolean =
|
override fun isICEnabled(): Boolean =
|
||||||
IncrementalCompilation.isEnabledForJvm()
|
IncrementalCompilation.isEnabledForJvm()
|
||||||
|
|
||||||
override fun createCacheManager(args: K2JVMCompilerArguments): IncrementalJvmCachesManager =
|
override fun createCacheManager(args: K2JVMCompilerArguments): IncrementalJvmCachesManager =
|
||||||
IncrementalJvmCachesManager(cacheDirectory, File(args.destination), reporter)
|
IncrementalJvmCachesManager(cacheDirectory, File(args.destination), reporter)
|
||||||
|
|
||||||
override fun destinationDir(args: K2JVMCompilerArguments): File =
|
override fun destinationDir(args: K2JVMCompilerArguments): File =
|
||||||
args.destinationAsFile
|
args.destinationAsFile
|
||||||
|
|
||||||
private var dirtyClasspathChanges: Collection<FqName> = emptySet<FqName>()
|
private var dirtyClasspathChanges: Collection<FqName> = emptySet()
|
||||||
|
|
||||||
private val psiFileFactory: PsiFileFactory by lazy {
|
private val psiFileFactory: PsiFileFactory by lazy {
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable()
|
||||||
@@ -139,10 +136,10 @@ class IncrementalJvmCompilerRunner(
|
|||||||
private val changedUntrackedJavaClasses = mutableSetOf<ClassId>()
|
private val changedUntrackedJavaClasses = mutableSetOf<ClassId>()
|
||||||
|
|
||||||
private var javaFilesProcessor =
|
private var javaFilesProcessor =
|
||||||
if (!usePreciseJavaTracking)
|
if (!usePreciseJavaTracking)
|
||||||
ChangedJavaFilesProcessor(reporter) { it.psiFile() }
|
ChangedJavaFilesProcessor(reporter) { it.psiFile() }
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
|
|
||||||
override fun calculateSourcesToCompile(
|
override fun calculateSourcesToCompile(
|
||||||
caches: IncrementalJvmCachesManager,
|
caches: IncrementalJvmCachesManager,
|
||||||
@@ -227,7 +224,7 @@ class IncrementalJvmCompilerRunner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun File.psiFile(): PsiFile? =
|
private fun File.psiFile(): PsiFile? =
|
||||||
psiFileFactory.createFileFromText(nameWithoutExtension, JavaLanguage.INSTANCE, readText())
|
psiFileFactory.createFileFromText(nameWithoutExtension, JavaLanguage.INSTANCE, readText())
|
||||||
|
|
||||||
private fun processChangedUntrackedJavaClass(psiClass: PsiClass, classId: ClassId) {
|
private fun processChangedUntrackedJavaClass(psiClass: PsiClass, classId: ClassId) {
|
||||||
changedUntrackedJavaClasses.add(classId)
|
changedUntrackedJavaClasses.add(classId)
|
||||||
@@ -259,23 +256,23 @@ class IncrementalJvmCompilerRunner(
|
|||||||
override fun postCompilationHook(exitCode: ExitCode) {}
|
override fun postCompilationHook(exitCode: ExitCode) {}
|
||||||
|
|
||||||
override fun updateCaches(
|
override fun updateCaches(
|
||||||
services: Services,
|
services: Services,
|
||||||
caches: IncrementalJvmCachesManager,
|
caches: IncrementalJvmCachesManager,
|
||||||
generatedFiles: List<GeneratedFile>,
|
generatedFiles: List<GeneratedFile>,
|
||||||
changesCollector: ChangesCollector
|
changesCollector: ChangesCollector
|
||||||
) {
|
) {
|
||||||
updateIncrementalCache(
|
updateIncrementalCache(
|
||||||
generatedFiles, caches.platformCache, changesCollector,
|
generatedFiles, caches.platformCache, changesCollector,
|
||||||
services[JavaClassesTracker::class.java] as? JavaClassesTrackerImpl
|
services[JavaClassesTracker::class.java] as? JavaClassesTrackerImpl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun runWithNoDirtyKotlinSources(caches: IncrementalJvmCachesManager): Boolean =
|
override fun runWithNoDirtyKotlinSources(caches: IncrementalJvmCachesManager): Boolean =
|
||||||
caches.platformCache.getObsoleteJavaClasses().isNotEmpty() || changedUntrackedJavaClasses.isNotEmpty()
|
caches.platformCache.getObsoleteJavaClasses().isNotEmpty() || changedUntrackedJavaClasses.isNotEmpty()
|
||||||
|
|
||||||
override fun additionalDirtyFiles(
|
override fun additionalDirtyFiles(
|
||||||
caches: IncrementalJvmCachesManager,
|
caches: IncrementalJvmCachesManager,
|
||||||
generatedFiles: List<GeneratedFile>
|
generatedFiles: List<GeneratedFile>
|
||||||
): Iterable<File> {
|
): Iterable<File> {
|
||||||
val cache = caches.platformCache
|
val cache = caches.platformCache
|
||||||
val result = HashSet<File>()
|
val result = HashSet<File>()
|
||||||
@@ -314,14 +311,14 @@ class IncrementalJvmCompilerRunner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun additionalDirtyLookupSymbols(): Iterable<LookupSymbol> =
|
override fun additionalDirtyLookupSymbols(): Iterable<LookupSymbol> =
|
||||||
javaFilesProcessor?.allChangedSymbols ?: emptyList()
|
javaFilesProcessor?.allChangedSymbols ?: emptyList()
|
||||||
|
|
||||||
override fun makeServices(
|
override fun makeServices(
|
||||||
args: K2JVMCompilerArguments,
|
args: K2JVMCompilerArguments,
|
||||||
lookupTracker: LookupTracker,
|
lookupTracker: LookupTracker,
|
||||||
expectActualTracker: ExpectActualTracker,
|
expectActualTracker: ExpectActualTracker,
|
||||||
caches: IncrementalJvmCachesManager,
|
caches: IncrementalJvmCachesManager,
|
||||||
compilationMode: CompilationMode
|
compilationMode: CompilationMode
|
||||||
): Services.Builder =
|
): Services.Builder =
|
||||||
super.makeServices(args, lookupTracker, expectActualTracker, caches, compilationMode).apply {
|
super.makeServices(args, lookupTracker, expectActualTracker, caches, compilationMode).apply {
|
||||||
val targetId = TargetId(args.moduleName!!, "java-production")
|
val targetId = TargetId(args.moduleName!!, "java-production")
|
||||||
@@ -336,11 +333,11 @@ class IncrementalJvmCompilerRunner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun runCompiler(
|
override fun runCompiler(
|
||||||
sourcesToCompile: Set<File>,
|
sourcesToCompile: Set<File>,
|
||||||
args: K2JVMCompilerArguments,
|
args: K2JVMCompilerArguments,
|
||||||
caches: IncrementalJvmCachesManager,
|
caches: IncrementalJvmCachesManager,
|
||||||
services: Services,
|
services: Services,
|
||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
val compiler = K2JVMCompiler()
|
val compiler = K2JVMCompiler()
|
||||||
val freeArgsBackup = args.freeArgs.toList()
|
val freeArgsBackup = args.freeArgs.toList()
|
||||||
@@ -353,9 +350,13 @@ class IncrementalJvmCompilerRunner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var K2JVMCompilerArguments.destinationAsFile: File
|
var K2JVMCompilerArguments.destinationAsFile: File
|
||||||
get() = File(destination)
|
get() = File(destination)
|
||||||
set(value) { destination = value.path }
|
set(value) {
|
||||||
|
destination = value.path
|
||||||
|
}
|
||||||
|
|
||||||
var K2JVMCompilerArguments.classpathAsList: List<File>
|
var K2JVMCompilerArguments.classpathAsList: List<File>
|
||||||
get() = classpath.orEmpty().split(File.pathSeparator).map(::File)
|
get() = classpath.orEmpty().split(File.pathSeparator).map(::File)
|
||||||
set(value) { classpath = value.joinToString(separator = File.pathSeparator, transform = { it.path }) }
|
set(value) {
|
||||||
|
classpath = value.joinToString(separator = File.pathSeparator, transform = { it.path })
|
||||||
|
}
|
||||||
|
|||||||
+7
-8
@@ -19,18 +19,17 @@ package org.jetbrains.kotlin.incremental
|
|||||||
import com.intellij.util.containers.MultiMap
|
import com.intellij.util.containers.MultiMap
|
||||||
import org.jetbrains.kotlin.build.GeneratedFile
|
import org.jetbrains.kotlin.build.GeneratedFile
|
||||||
import org.jetbrains.kotlin.incremental.snapshots.FileSnapshotMap
|
import org.jetbrains.kotlin.incremental.snapshots.FileSnapshotMap
|
||||||
import org.jetbrains.kotlin.incremental.storage.*
|
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
|
||||||
|
import org.jetbrains.kotlin.incremental.storage.SourceToOutputFilesMap
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
import kotlin.collections.HashSet
|
|
||||||
|
|
||||||
class InputsCache(
|
class InputsCache(
|
||||||
workingDir: File,
|
workingDir: File,
|
||||||
private val reporter: ICReporter
|
private val reporter: ICReporter
|
||||||
) : BasicMapsOwner(workingDir) {
|
) : BasicMapsOwner(workingDir) {
|
||||||
companion object {
|
companion object {
|
||||||
private val SOURCE_SNAPSHOTS = "source-snapshot"
|
private const val SOURCE_SNAPSHOTS = "source-snapshot"
|
||||||
private val SOURCE_TO_OUTPUT_FILES = "source-to-output"
|
private const val SOURCE_TO_OUTPUT_FILES = "source-to-output"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val sourceSnapshotMap = registerMap(FileSnapshotMap(SOURCE_SNAPSHOTS.storageFile))
|
internal val sourceSnapshotMap = registerMap(FileSnapshotMap(SOURCE_SNAPSHOTS.storageFile))
|
||||||
@@ -38,7 +37,7 @@ class InputsCache(
|
|||||||
|
|
||||||
fun removeOutputForSourceFiles(sources: Iterable<File>) {
|
fun removeOutputForSourceFiles(sources: Iterable<File>) {
|
||||||
for (sourceFile in sources) {
|
for (sourceFile in sources) {
|
||||||
sourceToOutputMap.remove(sourceFile).forEach { it ->
|
sourceToOutputMap.remove(sourceFile).forEach {
|
||||||
reporter.reportVerbose { "Deleting $it on clearing cache for $sourceFile" }
|
reporter.reportVerbose { "Deleting $it on clearing cache for $sourceFile" }
|
||||||
it.delete()
|
it.delete()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -192,7 +192,7 @@ class ModulesApiHistoryAndroid(modulesInfo: IncrementalModuleInfo) : ModulesApiH
|
|||||||
|
|
||||||
private fun getHistoryForModuleNames(path: Path, moduleNames: Iterable<String>): Either<Set<File>> {
|
private fun getHistoryForModuleNames(path: Path, moduleNames: Iterable<String>): Either<Set<File>> {
|
||||||
val possibleModules =
|
val possibleModules =
|
||||||
moduleNames.flatMapTo(HashSet<IncrementalModuleEntry>()) { modulesInfo.nameToModules[it] ?: emptySet() }
|
moduleNames.flatMapTo(HashSet()) { modulesInfo.nameToModules[it] ?: emptySet() }
|
||||||
val modules = possibleModules.filter { Paths.get(it.buildDir.absolutePath).isParentOf(path) }
|
val modules = possibleModules.filter { Paths.get(it.buildDir.absolutePath).isParentOf(path) }
|
||||||
if (modules.isEmpty()) return Either.Error("Unknown module for $path (candidates: ${possibleModules.joinToString()})")
|
if (modules.isEmpty()) return Either.Error("Unknown module for $path (candidates: ${possibleModules.joinToString()})")
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -20,9 +20,9 @@ import java.io.File
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class FileSnapshot(
|
class FileSnapshot(
|
||||||
val file: File,
|
val file: File,
|
||||||
val length: Long,
|
val length: Long,
|
||||||
val hash: ByteArray
|
val hash: ByteArray
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
assert(!file.isDirectory)
|
assert(!file.isDirectory)
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.*
|
|||||||
|
|
||||||
class FileSnapshotMap(storageFile: File) : BasicStringMap<FileSnapshot>(storageFile, PathStringDescriptor, FileSnapshotExternalizer) {
|
class FileSnapshotMap(storageFile: File) : BasicStringMap<FileSnapshot>(storageFile, PathStringDescriptor, FileSnapshotExternalizer) {
|
||||||
override fun dumpValue(value: FileSnapshot): String =
|
override fun dumpValue(value: FileSnapshot): String =
|
||||||
value.toString()
|
value.toString()
|
||||||
|
|
||||||
fun compareAndUpdate(newFiles: Iterable<File>): ChangedFiles.Known {
|
fun compareAndUpdate(newFiles: Iterable<File>): ChangedFiles.Known {
|
||||||
val snapshotProvider = SimpleFileSnapshotProviderImpl()
|
val snapshotProvider = SimpleFileSnapshotProviderImpl()
|
||||||
|
|||||||
Reference in New Issue
Block a user