[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, " +
|
"targetPlatform=$targetPlatform, " +
|
||||||
"reportCategories=${Arrays.toString(reportCategories)}, " +
|
"reportCategories=${Arrays.toString(reportCategories)}, " +
|
||||||
"reportSeverity=$reportSeverity, " +
|
"reportSeverity=$reportSeverity, " +
|
||||||
"requestedCompilationResults=${Arrays.toString(requestedCompilationResults)}" +
|
"requestedCompilationResults=${Arrays.toString(requestedCompilationResults)}, " +
|
||||||
"kotlinScriptExtensions=${Arrays.toString(kotlinScriptExtensions)}" +
|
"kotlinScriptExtensions=${Arrays.toString(kotlinScriptExtensions)}" +
|
||||||
")"
|
")"
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,8 @@ class IncrementalCompilationOptions(
|
|||||||
val multiModuleICSettings: MultiModuleICSettings,
|
val multiModuleICSettings: MultiModuleICSettings,
|
||||||
val modulesInfo: IncrementalModuleInfo,
|
val modulesInfo: IncrementalModuleInfo,
|
||||||
kotlinScriptExtensions: Array<String>? = null,
|
kotlinScriptExtensions: Array<String>? = null,
|
||||||
val withAbiSnapshot: Boolean = false
|
val withAbiSnapshot: Boolean = false,
|
||||||
|
val preciseCompilationResultsBackup: Boolean = false,
|
||||||
) : CompilationOptions(
|
) : CompilationOptions(
|
||||||
compilerMode,
|
compilerMode,
|
||||||
targetPlatform,
|
targetPlatform,
|
||||||
@@ -81,7 +82,7 @@ class IncrementalCompilationOptions(
|
|||||||
kotlinScriptExtensions
|
kotlinScriptExtensions
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID: Long = 0
|
const val serialVersionUID: Long = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
@@ -93,7 +94,7 @@ class IncrementalCompilationOptions(
|
|||||||
"classpathChanges=${classpathChanges::class.simpleName}, " +
|
"classpathChanges=${classpathChanges::class.simpleName}, " +
|
||||||
"workingDir=$workingDir, " +
|
"workingDir=$workingDir, " +
|
||||||
"multiModuleICSettings=$multiModuleICSettings, " +
|
"multiModuleICSettings=$multiModuleICSettings, " +
|
||||||
"usePreciseJavaTracking=$usePreciseJavaTracking" +
|
"usePreciseJavaTracking=$usePreciseJavaTracking, " +
|
||||||
"outputFiles=$outputFiles" +
|
"outputFiles=$outputFiles" +
|
||||||
")"
|
")"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -557,7 +557,8 @@ abstract class CompileServiceImplBase(
|
|||||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
||||||
scopeExpansion = if (args.isIrBackendEnabled()) CompileScopeExpansionMode.ALWAYS else CompileScopeExpansionMode.NEVER,
|
scopeExpansion = if (args.isIrBackendEnabled()) CompileScopeExpansionMode.ALWAYS else CompileScopeExpansionMode.NEVER,
|
||||||
modulesApiHistory = modulesApiHistory,
|
modulesApiHistory = modulesApiHistory,
|
||||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot
|
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot,
|
||||||
|
preciseCompilationResultsBackup = incrementalCompilationOptions.preciseCompilationResultsBackup,
|
||||||
)
|
)
|
||||||
return try {
|
return try {
|
||||||
compiler.compile(allKotlinFiles, args, compilerMessageCollector, changedFiles)
|
compiler.compile(allKotlinFiles, args, compilerMessageCollector, changedFiles)
|
||||||
@@ -616,7 +617,8 @@ abstract class CompileServiceImplBase(
|
|||||||
modulesApiHistory = modulesApiHistory,
|
modulesApiHistory = modulesApiHistory,
|
||||||
kotlinSourceFilesExtensions = allKotlinExtensions,
|
kotlinSourceFilesExtensions = allKotlinExtensions,
|
||||||
classpathChanges = incrementalCompilationOptions.classpathChanges,
|
classpathChanges = incrementalCompilationOptions.classpathChanges,
|
||||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot
|
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot,
|
||||||
|
preciseCompilationResultsBackup = incrementalCompilationOptions.preciseCompilationResultsBackup,
|
||||||
)
|
)
|
||||||
return try {
|
return try {
|
||||||
compiler.compile(allKotlinFiles, k2jvmArgs, compilerMessageCollector, changedFiles, projectRoot)
|
compiler.compile(allKotlinFiles, k2jvmArgs, compilerMessageCollector, changedFiles, projectRoot)
|
||||||
|
|||||||
+9
-2
@@ -70,7 +70,8 @@ abstract class IncrementalCompilerRunner<
|
|||||||
*/
|
*/
|
||||||
private val outputDirs: Collection<File>?,
|
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)
|
protected val cacheDirectory = File(workingDir, cacheDirName)
|
||||||
@@ -382,7 +383,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
performWorkBeforeCompilation(compilationMode, args)
|
performWorkBeforeCompilation(compilationMode, args)
|
||||||
|
|
||||||
val allKotlinFiles = allSourceFiles.filter { it.isKotlinFile(kotlinSourceFilesExtensions) }
|
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)
|
doCompile(compilationMode, allKotlinFiles, args, caches, abiSnapshotData, messageCollector, transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,6 +391,12 @@ abstract class IncrementalCompilerRunner<
|
|||||||
return exitCode
|
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 performWorkBeforeCompilation(compilationMode: CompilationMode, args: Args) {}
|
||||||
|
|
||||||
protected open fun performWorkAfterCompilation(compilationMode: CompilationMode, exitCode: ExitCode, caches: CacheManager) {
|
protected open fun performWorkAfterCompilation(compilationMode: CompilationMode, exitCode: ExitCode, caches: CacheManager) {
|
||||||
|
|||||||
+5
-3
@@ -87,14 +87,16 @@ class IncrementalJsCompilerRunner(
|
|||||||
buildHistoryFile: File,
|
buildHistoryFile: File,
|
||||||
private val modulesApiHistory: ModulesApiHistory,
|
private val modulesApiHistory: ModulesApiHistory,
|
||||||
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
|
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
|
||||||
withAbiSnapshot: Boolean = false
|
withAbiSnapshot: Boolean = false,
|
||||||
|
preciseCompilationResultsBackup: Boolean = false,
|
||||||
) : IncrementalCompilerRunner<K2JSCompilerArguments, IncrementalJsCachesManager>(
|
) : IncrementalCompilerRunner<K2JSCompilerArguments, IncrementalJsCachesManager>(
|
||||||
workingDir,
|
workingDir,
|
||||||
"caches-js",
|
"caches-js",
|
||||||
reporter,
|
reporter,
|
||||||
buildHistoryFile = buildHistoryFile,
|
buildHistoryFile = buildHistoryFile,
|
||||||
outputDirs = null,
|
outputDirs = null,
|
||||||
withAbiSnapshot = withAbiSnapshot
|
withAbiSnapshot = withAbiSnapshot,
|
||||||
|
preciseCompilationResultsBackup = preciseCompilationResultsBackup,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun createCacheManager(args: K2JSCompilerArguments, projectDir: File?): IncrementalJsCachesManager {
|
override fun createCacheManager(args: K2JSCompilerArguments, projectDir: File?): IncrementalJsCachesManager {
|
||||||
@@ -105,7 +107,7 @@ class IncrementalJsCompilerRunner(
|
|||||||
reporter,
|
reporter,
|
||||||
serializerProtocol,
|
serializerProtocol,
|
||||||
storeFullFqNamesInLookupCache = withAbiSnapshot
|
storeFullFqNamesInLookupCache = withAbiSnapshot
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun destinationDir(args: K2JSCompilerArguments): File {
|
override fun destinationDir(args: K2JSCompilerArguments): File {
|
||||||
|
|||||||
+4
-2
@@ -139,14 +139,16 @@ open class IncrementalJvmCompilerRunner(
|
|||||||
private val modulesApiHistory: ModulesApiHistory,
|
private val modulesApiHistory: ModulesApiHistory,
|
||||||
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
|
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
|
||||||
private val classpathChanges: ClasspathChanges,
|
private val classpathChanges: ClasspathChanges,
|
||||||
withAbiSnapshot: Boolean = false
|
withAbiSnapshot: Boolean = false,
|
||||||
|
preciseCompilationResultsBackup: Boolean = false,
|
||||||
) : IncrementalCompilerRunner<K2JVMCompilerArguments, IncrementalJvmCachesManager>(
|
) : IncrementalCompilerRunner<K2JVMCompilerArguments, IncrementalJvmCachesManager>(
|
||||||
workingDir,
|
workingDir,
|
||||||
"caches-jvm",
|
"caches-jvm",
|
||||||
reporter,
|
reporter,
|
||||||
buildHistoryFile = buildHistoryFile,
|
buildHistoryFile = buildHistoryFile,
|
||||||
outputDirs = outputDirs,
|
outputDirs = outputDirs,
|
||||||
withAbiSnapshot = withAbiSnapshot
|
withAbiSnapshot = withAbiSnapshot,
|
||||||
|
preciseCompilationResultsBackup = preciseCompilationResultsBackup,
|
||||||
) {
|
) {
|
||||||
override fun createCacheManager(args: K2JVMCompilerArguments, projectDir: File?): IncrementalJvmCachesManager =
|
override fun createCacheManager(args: K2JVMCompilerArguments, projectDir: File?): IncrementalJvmCachesManager =
|
||||||
IncrementalJvmCachesManager(
|
IncrementalJvmCachesManager(
|
||||||
|
|||||||
+2
-1
@@ -294,7 +294,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
multiModuleICSettings = icEnv.multiModuleICSettings,
|
multiModuleICSettings = icEnv.multiModuleICSettings,
|
||||||
modulesInfo = incrementalModuleInfo!!,
|
modulesInfo = incrementalModuleInfo!!,
|
||||||
kotlinScriptExtensions = kotlinScriptExtensions,
|
kotlinScriptExtensions = kotlinScriptExtensions,
|
||||||
withAbiSnapshot = icEnv.withAbiSnapshot
|
withAbiSnapshot = icEnv.withAbiSnapshot,
|
||||||
|
preciseCompilationResultsBackup = icEnv.preciseCompilationResultsBackup,
|
||||||
)
|
)
|
||||||
|
|
||||||
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
||||||
|
|||||||
+3
-2
@@ -18,9 +18,10 @@ internal class IncrementalCompilationEnvironment(
|
|||||||
val usePreciseJavaTracking: Boolean = false,
|
val usePreciseJavaTracking: Boolean = false,
|
||||||
val disableMultiModuleIC: Boolean = false,
|
val disableMultiModuleIC: Boolean = false,
|
||||||
val multiModuleICSettings: MultiModuleICSettings,
|
val multiModuleICSettings: MultiModuleICSettings,
|
||||||
val withAbiSnapshot: Boolean = false
|
val withAbiSnapshot: Boolean = false,
|
||||||
|
val preciseCompilationResultsBackup: Boolean = false,
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
companion object {
|
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.internal.testing.TCServiceMessageOutputStreamHandler.Companion.IGNORE_TCSM_OVERFLOW
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.Companion.jsCompilerProperty
|
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_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_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_GRADLE_PLUGIN_COMPATIBILITY_NO_WARN
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_ANDROID_STYLE_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
|
val kotlinDaemonUseFallbackStrategy: Boolean
|
||||||
get() = booleanProperty("kotlin.daemon.useFallbackStrategy") ?: true
|
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]
|
* Retrieves a comma-separated list of browsers to use when running karma tests for [target]
|
||||||
* @see KOTLIN_JS_KARMA_BROWSERS
|
* @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_BUILD_REPORT_HTTP_URL = "kotlin.build.report.http.url"
|
||||||
const val KOTLIN_OPTIONS_SUPPRESS_FREEARGS_MODIFICATION_WARNING = "kotlin.options.suppressFreeCompilerArgsModificationWarning"
|
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_NATIVE_USE_XCODE_MESSAGE_STYLE = "kotlin.native.useXcodeMessageStyle"
|
||||||
|
const val KOTLIN_COMPILER_USE_PRECISE_COMPILATION_RESULTS_BACKUP = "kotlin.compiler.preciseCompilationResultsBackup"
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+15
-4
@@ -381,10 +381,19 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
|
|||||||
|
|
||||||
private val systemPropertiesService = CompilerSystemPropertiesService.registerIfAbsent(project.gradle)
|
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). */
|
/** Task outputs that we don't want to include in [TaskOutputsBackup] (see [TaskOutputsBackup.outputsToRestore] for more info). */
|
||||||
@get:Internal
|
@get:Internal
|
||||||
protected open val taskOutputsBackupExcludes: List<File>
|
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
|
@TaskAction
|
||||||
fun execute(inputChanges: InputChanges) {
|
fun execute(inputChanges: InputChanges) {
|
||||||
@@ -749,11 +758,12 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
usePreciseJavaTracking = usePreciseJavaTracking,
|
usePreciseJavaTracking = usePreciseJavaTracking,
|
||||||
disableMultiModuleIC = disableMultiModuleIC,
|
disableMultiModuleIC = disableMultiModuleIC,
|
||||||
multiModuleICSettings = multiModuleICSettings,
|
multiModuleICSettings = multiModuleICSettings,
|
||||||
withAbiSnapshot = useKotlinAbiSnapshot.get()
|
withAbiSnapshot = useKotlinAbiSnapshot.get(),
|
||||||
|
preciseCompilationResultsBackup = preciseCompilationResultsBackup.get(),
|
||||||
)
|
)
|
||||||
} else null
|
} else null
|
||||||
|
|
||||||
@Suppress("ConvertArgumentToSet", "DEPRECATION")
|
@Suppress("ConvertArgumentToSet")
|
||||||
val environment = GradleCompilerEnvironment(
|
val environment = GradleCompilerEnvironment(
|
||||||
defaultCompilerClasspath, gradleMessageCollector, outputItemCollector,
|
defaultCompilerClasspath, gradleMessageCollector, outputItemCollector,
|
||||||
// In the incremental compiler, outputFiles will be cleaned on rebuild. However, because classpathSnapshotDir is not included in
|
// 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),
|
getChangedFiles(inputChanges, incrementalProps),
|
||||||
ClasspathChanges.NotAvailableForJSCompiler,
|
ClasspathChanges.NotAvailableForJSCompiler,
|
||||||
taskBuildCacheableOutputDirectory.get().asFile,
|
taskBuildCacheableOutputDirectory.get().asFile,
|
||||||
multiModuleICSettings = multiModuleICSettings
|
multiModuleICSettings = multiModuleICSettings,
|
||||||
|
preciseCompilationResultsBackup = preciseCompilationResultsBackup.get(),
|
||||||
)
|
)
|
||||||
} else null
|
} else null
|
||||||
|
|
||||||
|
|||||||
+4
@@ -77,6 +77,10 @@ internal abstract class AbstractKotlinCompileConfig<TASK : AbstractKotlinCompile
|
|||||||
.convention(propertiesProvider.kotlinOptionsSuppressFreeArgsModificationWarning)
|
.convention(propertiesProvider.kotlinOptionsSuppressFreeArgsModificationWarning)
|
||||||
.finalizeValueOnRead()
|
.finalizeValueOnRead()
|
||||||
|
|
||||||
|
task.preciseCompilationResultsBackup
|
||||||
|
.convention(propertiesProvider.preciseCompilationResultsBackup)
|
||||||
|
.finalizeValueOnRead()
|
||||||
|
|
||||||
task.incremental = false
|
task.incremental = false
|
||||||
task.useModuleDetection.convention(false)
|
task.useModuleDetection.convention(false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user