[Gradle, IC] Add gradle property to control precise compilation outputs backup
#KT-49785 In Progress
This commit is contained in:
committed by
Space Team
parent
6a91dd6bac
commit
20ed029ba5
+5
-4
@@ -43,7 +43,7 @@ open class CompilationOptions(
|
||||
"targetPlatform=$targetPlatform, " +
|
||||
"reportCategories=${Arrays.toString(reportCategories)}, " +
|
||||
"reportSeverity=$reportSeverity, " +
|
||||
"requestedCompilationResults=${Arrays.toString(requestedCompilationResults)}" +
|
||||
"requestedCompilationResults=${Arrays.toString(requestedCompilationResults)}, " +
|
||||
"kotlinScriptExtensions=${Arrays.toString(kotlinScriptExtensions)}" +
|
||||
")"
|
||||
}
|
||||
@@ -71,7 +71,8 @@ class IncrementalCompilationOptions(
|
||||
val multiModuleICSettings: MultiModuleICSettings,
|
||||
val modulesInfo: IncrementalModuleInfo,
|
||||
kotlinScriptExtensions: Array<String>? = null,
|
||||
val withAbiSnapshot: Boolean = false
|
||||
val withAbiSnapshot: Boolean = false,
|
||||
val preciseCompilationResultsBackup: Boolean = false,
|
||||
) : CompilationOptions(
|
||||
compilerMode,
|
||||
targetPlatform,
|
||||
@@ -81,7 +82,7 @@ class IncrementalCompilationOptions(
|
||||
kotlinScriptExtensions
|
||||
) {
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 0
|
||||
const val serialVersionUID: Long = 1
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
@@ -93,7 +94,7 @@ class IncrementalCompilationOptions(
|
||||
"classpathChanges=${classpathChanges::class.simpleName}, " +
|
||||
"workingDir=$workingDir, " +
|
||||
"multiModuleICSettings=$multiModuleICSettings, " +
|
||||
"usePreciseJavaTracking=$usePreciseJavaTracking" +
|
||||
"usePreciseJavaTracking=$usePreciseJavaTracking, " +
|
||||
"outputFiles=$outputFiles" +
|
||||
")"
|
||||
}
|
||||
|
||||
@@ -557,7 +557,8 @@ abstract class CompileServiceImplBase(
|
||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
||||
scopeExpansion = if (args.isIrBackendEnabled()) CompileScopeExpansionMode.ALWAYS else CompileScopeExpansionMode.NEVER,
|
||||
modulesApiHistory = modulesApiHistory,
|
||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot
|
||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot,
|
||||
preciseCompilationResultsBackup = incrementalCompilationOptions.preciseCompilationResultsBackup,
|
||||
)
|
||||
return try {
|
||||
compiler.compile(allKotlinFiles, args, compilerMessageCollector, changedFiles)
|
||||
@@ -616,7 +617,8 @@ abstract class CompileServiceImplBase(
|
||||
modulesApiHistory = modulesApiHistory,
|
||||
kotlinSourceFilesExtensions = allKotlinExtensions,
|
||||
classpathChanges = incrementalCompilationOptions.classpathChanges,
|
||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot
|
||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot,
|
||||
preciseCompilationResultsBackup = incrementalCompilationOptions.preciseCompilationResultsBackup,
|
||||
)
|
||||
return try {
|
||||
compiler.compile(allKotlinFiles, k2jvmArgs, compilerMessageCollector, changedFiles, projectRoot)
|
||||
|
||||
+9
-2
@@ -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) {
|
||||
|
||||
+5
-3
@@ -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 {
|
||||
|
||||
+4
-2
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user