[BT] Add support for in-process incremental compilation

#KT-61865 Fixed
This commit is contained in:
Alexander.Likhachev
2023-09-13 05:45:00 +02:00
committed by Space Team
parent fb1d2278a0
commit b460c06907
14 changed files with 139 additions and 61 deletions
@@ -12,7 +12,7 @@ import java.io.File
class DirtyFilesContainer(
private val caches: IncrementalCachesManager<*>,
private val reporter: ICReporter,
private val sourceFilesExtensions: List<String>
private val sourceFilesExtensions: Set<String>
) {
private val myDirtyFiles = HashSet<File>()
@@ -81,7 +81,7 @@ abstract class IncrementalCompilerRunner<
private val dirtySourcesSinceLastTimeFile = File(workingDir, DIRTY_SOURCES_FILE_NAME)
protected val lastBuildInfoFile = File(workingDir, LAST_BUILD_INFO_FILE_NAME)
private val abiSnapshotFile = File(workingDir, ABI_SNAPSHOT_FILE_NAME)
protected open val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
protected open val kotlinSourceFilesExtensions: Set<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
/**
* Creates an instance of [IncrementalCompilationContext] that holds common incremental compilation context mostly required for [CacheManager]
@@ -663,3 +663,23 @@ abstract class IncrementalCompilerRunner<
}
}
}
@Deprecated("Temporary function to reuse the logic. KT-62759")
fun extractKotlinSourcesFromFreeCompilerArguments(
compilerArguments: CommonCompilerArguments,
kotlinFilenameExtensions: Set<String>,
): List<File> {
val dotExtensions = kotlinFilenameExtensions.map { ".$it" }
val freeArgs = arrayListOf<String>()
val allKotlinFiles = arrayListOf<File>()
for (arg in compilerArguments.freeArgs) {
val file = File(arg)
if (file.isFile && dotExtensions.any { ext -> file.path.endsWith(ext, ignoreCase = true) }) {
allKotlinFiles.add(file)
} else {
freeArgs.add(arg)
}
}
compilerArguments.freeArgs = freeArgs
return allKotlinFiles
}
@@ -64,7 +64,7 @@ open class IncrementalFirJvmCompilerRunner(
buildHistoryFile: File?,
outputDirs: Collection<File>?,
modulesApiHistory: ModulesApiHistory,
kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
kotlinSourceFilesExtensions: Set<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
classpathChanges: ClasspathChanges
) : IncrementalJvmCompilerRunner(
workingDir,
@@ -66,7 +66,7 @@ open class IncrementalJvmCompilerRunner(
buildHistoryFile: File?,
outputDirs: Collection<File>?,
private val modulesApiHistory: ModulesApiHistory,
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
override val kotlinSourceFilesExtensions: Set<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
private val classpathChanges: ClasspathChanges,
withAbiSnapshot: Boolean = false,
preciseCompilationResultsBackup: Boolean = false,
@@ -18,7 +18,7 @@ class IncrementalFirJvmCompilerTestRunner(
buildHistoryFile: File,
outputDirs: Collection<File>?,
modulesApiHistory: ModulesApiHistory,
kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
kotlinSourceFilesExtensions: Set<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
classpathChanges: ClasspathChanges,
val testLookupTracker: TestLookupTracker
) : IncrementalFirJvmCompilerRunner(
@@ -19,7 +19,7 @@ class IncrementalJvmCompilerTestRunner(
buildHistoryFile: File,
outputDirs: Collection<File>?,
modulesApiHistory: ModulesApiHistory,
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
override val kotlinSourceFilesExtensions: Set<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
classpathChanges: ClasspathChanges,
withAbiSnapshot: Boolean = false,
val testLookupTracker: TestLookupTracker