[Gradle] Add a property to control if the IC caches in-memory wrapper is enabled

#KT-56052 In Progress
This commit is contained in:
Alexander.Likhachev
2023-01-25 20:25:36 +01:00
committed by Space Team
parent e7e5a3488b
commit 3ed651a7a6
13 changed files with 56 additions and 19 deletions
@@ -72,6 +72,7 @@ abstract class IncrementalCompilerRunner<
protected val withAbiSnapshot: Boolean = false,
private val preciseCompilationResultsBackup: Boolean = false,
private val keepIncrementalCompilationCachesInMemory: Boolean = false,
) {
protected val cacheDirectory = File(workingDir, cacheDirName)
@@ -83,10 +84,21 @@ abstract class IncrementalCompilerRunner<
/**
* Creates an instance of [IncrementalCompilationContext] that holds common incremental compilation context mostly required for [CacheManager]
*/
protected abstract fun createIncrementalCompilationContext(
private fun createIncrementalCompilationContext(
projectDir: File?,
transaction: CompilationTransaction
): IncrementalCompilationContext
) = IncrementalCompilationContext(
transaction = transaction,
rootProjectDir = projectDir,
reporter = reporter,
trackChangesInLookupCache = shouldTrackChangesInLookupCache,
storeFullFqNamesInLookupCache = shouldStoreFullFqNamesInLookupCache,
keepIncrementalCompilationCachesInMemory = keepIncrementalCompilationCachesInMemory,
)
protected abstract val shouldTrackChangesInLookupCache: Boolean
protected abstract val shouldStoreFullFqNamesInLookupCache: Boolean
protected abstract fun createCacheManager(icContext: IncrementalCompilationContext, args: Args): CacheManager
protected abstract fun destinationDir(args: Args): File
@@ -89,6 +89,7 @@ class IncrementalJsCompilerRunner(
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
withAbiSnapshot: Boolean = false,
preciseCompilationResultsBackup: Boolean = false,
keepIncrementalCompilationCachesInMemory: Boolean = false,
) : IncrementalCompilerRunner<K2JSCompilerArguments, IncrementalJsCachesManager>(
workingDir,
"caches-js",
@@ -97,14 +98,13 @@ class IncrementalJsCompilerRunner(
outputDirs = null,
withAbiSnapshot = withAbiSnapshot,
preciseCompilationResultsBackup = preciseCompilationResultsBackup,
keepIncrementalCompilationCachesInMemory = keepIncrementalCompilationCachesInMemory,
) {
override fun createIncrementalCompilationContext(projectDir: File?, transaction: CompilationTransaction) =
IncrementalCompilationContext(
transaction = transaction,
rootProjectDir = projectDir,
reporter = reporter,
storeFullFqNamesInLookupCache = withAbiSnapshot,
)
override val shouldTrackChangesInLookupCache
get() = false
override val shouldStoreFullFqNamesInLookupCache
get() = withAbiSnapshot
override fun createCacheManager(icContext: IncrementalCompilationContext, args: K2JSCompilerArguments) =
IncrementalJsCachesManager(icContext, if (!args.isIrBackendEnabled()) JsSerializerProtocol else KlibMetadataSerializerProtocol, cacheDirectory)
@@ -142,6 +142,7 @@ open class IncrementalJvmCompilerRunner(
private val classpathChanges: ClasspathChanges,
withAbiSnapshot: Boolean = false,
preciseCompilationResultsBackup: Boolean = false,
keepIncrementalCompilationCachesInMemory: Boolean = false,
) : IncrementalCompilerRunner<K2JVMCompilerArguments, IncrementalJvmCachesManager>(
workingDir,
"caches-jvm",
@@ -150,15 +151,13 @@ open class IncrementalJvmCompilerRunner(
outputDirs = outputDirs,
withAbiSnapshot = withAbiSnapshot,
preciseCompilationResultsBackup = preciseCompilationResultsBackup,
keepIncrementalCompilationCachesInMemory = keepIncrementalCompilationCachesInMemory,
) {
override fun createIncrementalCompilationContext(projectDir: File?, transaction: CompilationTransaction) =
IncrementalCompilationContext(
transaction = transaction,
rootProjectDir = projectDir,
reporter = reporter,
trackChangesInLookupCache = classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled.IncrementalRun,
storeFullFqNamesInLookupCache = withAbiSnapshot || classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled,
)
override val shouldTrackChangesInLookupCache
get() = classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled.IncrementalRun
override val shouldStoreFullFqNamesInLookupCache
get() = withAbiSnapshot || classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled
override fun createCacheManager(icContext: IncrementalCompilationContext, args: K2JVMCompilerArguments) =
IncrementalJvmCachesManager(icContext, args.destination?.let { File(it) }, cacheDirectory)