[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(
|
||||
|
||||
+2
-1
@@ -294,7 +294,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
||||
multiModuleICSettings = icEnv.multiModuleICSettings,
|
||||
modulesInfo = incrementalModuleInfo!!,
|
||||
kotlinScriptExtensions = kotlinScriptExtensions,
|
||||
withAbiSnapshot = icEnv.withAbiSnapshot
|
||||
withAbiSnapshot = icEnv.withAbiSnapshot,
|
||||
preciseCompilationResultsBackup = icEnv.preciseCompilationResultsBackup,
|
||||
)
|
||||
|
||||
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
||||
|
||||
+3
-2
@@ -18,9 +18,10 @@ internal class IncrementalCompilationEnvironment(
|
||||
val usePreciseJavaTracking: Boolean = false,
|
||||
val disableMultiModuleIC: Boolean = false,
|
||||
val multiModuleICSettings: MultiModuleICSettings,
|
||||
val withAbiSnapshot: Boolean = false
|
||||
val withAbiSnapshot: Boolean = false,
|
||||
val preciseCompilationResultsBackup: Boolean = false,
|
||||
) : Serializable {
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 1
|
||||
const val serialVersionUID: Long = 2
|
||||
}
|
||||
}
|
||||
+5
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.gradle.dsl.NativeCacheOrchestration
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessageOutputStreamHandler.Companion.IGNORE_TCSM_OVERFLOW
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.Companion.jsCompilerProperty
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_ABI_SNAPSHOT
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_COMPILER_USE_PRECISE_COMPILATION_RESULTS_BACKUP
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_JS_KARMA_BROWSERS
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ANDROID_GRADLE_PLUGIN_COMPATIBILITY_NO_WARN
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_ANDROID_STYLE_NO_WARN
|
||||
@@ -483,6 +484,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val kotlinDaemonUseFallbackStrategy: Boolean
|
||||
get() = booleanProperty("kotlin.daemon.useFallbackStrategy") ?: true
|
||||
|
||||
val preciseCompilationResultsBackup: Boolean
|
||||
get() = booleanProperty(KOTLIN_COMPILER_USE_PRECISE_COMPILATION_RESULTS_BACKUP) ?: false
|
||||
|
||||
/**
|
||||
* Retrieves a comma-separated list of browsers to use when running karma tests for [target]
|
||||
* @see KOTLIN_JS_KARMA_BROWSERS
|
||||
@@ -556,6 +560,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
const val KOTLIN_BUILD_REPORT_HTTP_URL = "kotlin.build.report.http.url"
|
||||
const val KOTLIN_OPTIONS_SUPPRESS_FREEARGS_MODIFICATION_WARNING = "kotlin.options.suppressFreeCompilerArgsModificationWarning"
|
||||
const val KOTLIN_NATIVE_USE_XCODE_MESSAGE_STYLE = "kotlin.native.useXcodeMessageStyle"
|
||||
const val KOTLIN_COMPILER_USE_PRECISE_COMPILATION_RESULTS_BACKUP = "kotlin.compiler.preciseCompilationResultsBackup"
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+15
-4
@@ -381,10 +381,19 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
|
||||
|
||||
private val systemPropertiesService = CompilerSystemPropertiesService.registerIfAbsent(project.gradle)
|
||||
|
||||
@get:Internal
|
||||
internal abstract val preciseCompilationResultsBackup: Property<Boolean>
|
||||
|
||||
/** Task outputs that we don't want to include in [TaskOutputsBackup] (see [TaskOutputsBackup.outputsToRestore] for more info). */
|
||||
@get:Internal
|
||||
protected open val taskOutputsBackupExcludes: List<File>
|
||||
get() = listOf(destinationDirectory.get().asFile)
|
||||
get() {
|
||||
val list = mutableListOf<File>()
|
||||
if (preciseCompilationResultsBackup.get()) {
|
||||
list.add(destinationDirectory.get().asFile)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun execute(inputChanges: InputChanges) {
|
||||
@@ -749,11 +758,12 @@ abstract class KotlinCompile @Inject constructor(
|
||||
usePreciseJavaTracking = usePreciseJavaTracking,
|
||||
disableMultiModuleIC = disableMultiModuleIC,
|
||||
multiModuleICSettings = multiModuleICSettings,
|
||||
withAbiSnapshot = useKotlinAbiSnapshot.get()
|
||||
withAbiSnapshot = useKotlinAbiSnapshot.get(),
|
||||
preciseCompilationResultsBackup = preciseCompilationResultsBackup.get(),
|
||||
)
|
||||
} else null
|
||||
|
||||
@Suppress("ConvertArgumentToSet", "DEPRECATION")
|
||||
@Suppress("ConvertArgumentToSet")
|
||||
val environment = GradleCompilerEnvironment(
|
||||
defaultCompilerClasspath, gradleMessageCollector, outputItemCollector,
|
||||
// In the incremental compiler, outputFiles will be cleaned on rebuild. However, because classpathSnapshotDir is not included in
|
||||
@@ -1175,7 +1185,8 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
||||
getChangedFiles(inputChanges, incrementalProps),
|
||||
ClasspathChanges.NotAvailableForJSCompiler,
|
||||
taskBuildCacheableOutputDirectory.get().asFile,
|
||||
multiModuleICSettings = multiModuleICSettings
|
||||
multiModuleICSettings = multiModuleICSettings,
|
||||
preciseCompilationResultsBackup = preciseCompilationResultsBackup.get(),
|
||||
)
|
||||
} else null
|
||||
|
||||
|
||||
+4
@@ -77,6 +77,10 @@ internal abstract class AbstractKotlinCompileConfig<TASK : AbstractKotlinCompile
|
||||
.convention(propertiesProvider.kotlinOptionsSuppressFreeArgsModificationWarning)
|
||||
.finalizeValueOnRead()
|
||||
|
||||
task.preciseCompilationResultsBackup
|
||||
.convention(propertiesProvider.preciseCompilationResultsBackup)
|
||||
.finalizeValueOnRead()
|
||||
|
||||
task.incremental = false
|
||||
task.useModuleDetection.convention(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user