[Gradle, IC] Add gradle property to control precise compilation outputs backup

#KT-49785 In Progress
This commit is contained in:
Alexander Likhachev
2022-11-18 20:07:38 +01:00
committed by Space Team
parent 6a91dd6bac
commit 20ed029ba5
10 changed files with 56 additions and 20 deletions
@@ -70,7 +70,8 @@ abstract class IncrementalCompilerRunner<
*/
private val outputDirs: Collection<File>?,
protected val withAbiSnapshot: Boolean = false
protected val withAbiSnapshot: Boolean = false,
private val preciseCompilationResultsBackup: Boolean = false,
) {
protected val cacheDirectory = File(workingDir, cacheDirName)
@@ -382,7 +383,7 @@ abstract class IncrementalCompilerRunner<
performWorkBeforeCompilation(compilationMode, args)
val allKotlinFiles = allSourceFiles.filter { it.isKotlinFile(kotlinSourceFilesExtensions) }
val exitCode = RecoverableCompilationTransaction(reporter, Files.createTempDirectory("kotlin-backups")).use { transaction ->
val exitCode = createTransaction().use { transaction ->
doCompile(compilationMode, allKotlinFiles, args, caches, abiSnapshotData, messageCollector, transaction)
}
@@ -390,6 +391,12 @@ abstract class IncrementalCompilerRunner<
return exitCode
}
private fun createTransaction() = if (preciseCompilationResultsBackup) {
RecoverableCompilationTransaction(reporter, Files.createTempDirectory("kotlin-backups"))
} else {
DummyCompilationTransaction()
}
protected open fun performWorkBeforeCompilation(compilationMode: CompilationMode, args: Args) {}
protected open fun performWorkAfterCompilation(compilationMode: CompilationMode, exitCode: ExitCode, caches: CacheManager) {
@@ -87,14 +87,16 @@ class IncrementalJsCompilerRunner(
buildHistoryFile: File,
private val modulesApiHistory: ModulesApiHistory,
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
withAbiSnapshot: Boolean = false
withAbiSnapshot: Boolean = false,
preciseCompilationResultsBackup: Boolean = false,
) : IncrementalCompilerRunner<K2JSCompilerArguments, IncrementalJsCachesManager>(
workingDir,
"caches-js",
reporter,
buildHistoryFile = buildHistoryFile,
outputDirs = null,
withAbiSnapshot = withAbiSnapshot
withAbiSnapshot = withAbiSnapshot,
preciseCompilationResultsBackup = preciseCompilationResultsBackup,
) {
override fun createCacheManager(args: K2JSCompilerArguments, projectDir: File?): IncrementalJsCachesManager {
@@ -105,7 +107,7 @@ class IncrementalJsCompilerRunner(
reporter,
serializerProtocol,
storeFullFqNamesInLookupCache = withAbiSnapshot
)
)
}
override fun destinationDir(args: K2JSCompilerArguments): File {
@@ -139,14 +139,16 @@ open class IncrementalJvmCompilerRunner(
private val modulesApiHistory: ModulesApiHistory,
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
private val classpathChanges: ClasspathChanges,
withAbiSnapshot: Boolean = false
withAbiSnapshot: Boolean = false,
preciseCompilationResultsBackup: Boolean = false,
) : IncrementalCompilerRunner<K2JVMCompilerArguments, IncrementalJvmCachesManager>(
workingDir,
"caches-jvm",
reporter,
buildHistoryFile = buildHistoryFile,
outputDirs = outputDirs,
withAbiSnapshot = withAbiSnapshot
withAbiSnapshot = withAbiSnapshot,
preciseCompilationResultsBackup = preciseCompilationResultsBackup,
) {
override fun createCacheManager(args: K2JVMCompilerArguments, projectDir: File?): IncrementalJvmCachesManager =
IncrementalJvmCachesManager(