Use separate system properties to control IC for JVM and JS
Also this commit effectively disables JS IC by default
#KT-25563 fixed
This commit is contained in:
@@ -383,7 +383,7 @@ class MultifileClassCodegenImpl(
|
||||
private fun getCompiledPackageFragment(
|
||||
facadeFqName: FqName, state: GenerationState
|
||||
): IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment? {
|
||||
if (!IncrementalCompilation.isEnabled()) return null
|
||||
if (!IncrementalCompilation.isEnabledForJvm()) return null
|
||||
|
||||
val packageFqName = facadeFqName.parent()
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
override fun setupPlatformSpecificArgumentsAndServices(
|
||||
configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments, services: Services
|
||||
) {
|
||||
if (IncrementalCompilation.isEnabled()) {
|
||||
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||
services.get(LookupTracker::class.java)?.let {
|
||||
configuration.put(CommonConfigurationKeys.LOOKUP_TRACKER, it)
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.daemon.common.*
|
||||
import org.jetbrains.kotlin.daemon.report.CompileServicesFacadeMessageCollector
|
||||
@@ -469,7 +470,7 @@ class CompileServiceImpl(
|
||||
}
|
||||
|
||||
val workingDir = incrementalCompilationOptions.workingDir
|
||||
val versions = commonCacheVersions(workingDir) +
|
||||
val versions = commonCacheVersions(workingDir, enabled = true) +
|
||||
customCacheVersion(incrementalCompilationOptions.customCacheVersion,
|
||||
incrementalCompilationOptions.customCacheVersionFileName,
|
||||
workingDir,
|
||||
@@ -519,7 +520,7 @@ class CompileServiceImpl(
|
||||
}
|
||||
|
||||
val workingDir = incrementalCompilationOptions.workingDir
|
||||
val versions = commonCacheVersions(workingDir) +
|
||||
val versions = commonCacheVersions(workingDir, enabled = true) +
|
||||
customCacheVersion(incrementalCompilationOptions.customCacheVersion,
|
||||
incrementalCompilationOptions.customCacheVersionFileName,
|
||||
workingDir,
|
||||
|
||||
+6
-6
@@ -37,7 +37,8 @@ fun makeJsIncrementally(
|
||||
messageCollector: MessageCollector = MessageCollector.NONE,
|
||||
reporter: ICReporter = EmptyICReporter
|
||||
) {
|
||||
val versions = commonCacheVersions(cachesDir) + standaloneCacheVersion(cachesDir)
|
||||
val isIncremental = IncrementalCompilation.isEnabledForJs()
|
||||
val versions = commonCacheVersions(cachesDir, isIncremental) + standaloneCacheVersion(cachesDir, isIncremental)
|
||||
val allKotlinFiles = sourceRoots.asSequence().flatMap { it.walk() }
|
||||
.filter { it.isFile && it.extension.equals("kt", ignoreCase = true) }.toList()
|
||||
|
||||
@@ -47,14 +48,13 @@ fun makeJsIncrementally(
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <R> withJsIC(fn: ()->R): R {
|
||||
inline fun <R> withJsIC(fn: () -> R): R {
|
||||
val isJsEnabledBackup = IncrementalCompilation.isEnabledForJs()
|
||||
IncrementalCompilation.setIsEnabledForJs(true)
|
||||
|
||||
try {
|
||||
return withIC { fn() }
|
||||
}
|
||||
finally {
|
||||
return fn()
|
||||
} finally {
|
||||
IncrementalCompilation.setIsEnabledForJs(isJsEnabledBackup)
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class IncrementalJsCompilerRunner(
|
||||
reporter
|
||||
) {
|
||||
override fun isICEnabled(): Boolean =
|
||||
IncrementalCompilation.isEnabled() && IncrementalCompilation.isEnabledForJs()
|
||||
IncrementalCompilation.isEnabledForJs()
|
||||
|
||||
override fun createCacheManager(args: K2JSCompilerArguments): IncrementalJsCachesManager =
|
||||
IncrementalJsCachesManager(cacheDirectory, reporter)
|
||||
|
||||
+4
-3
@@ -56,7 +56,8 @@ fun makeIncrementally(
|
||||
messageCollector: MessageCollector = MessageCollector.NONE,
|
||||
reporter: ICReporter = EmptyICReporter
|
||||
) {
|
||||
val versions = commonCacheVersions(cachesDir) + standaloneCacheVersion(cachesDir)
|
||||
val isIncremental = IncrementalCompilation.isEnabledForJvm()
|
||||
val versions = commonCacheVersions(cachesDir, isIncremental) + standaloneCacheVersion(cachesDir, isIncremental)
|
||||
|
||||
val kotlinExtensions = listOf("kt", "kts")
|
||||
val allExtensions = kotlinExtensions + listOf("java")
|
||||
@@ -86,7 +87,7 @@ object EmptyICReporter : ICReporter {
|
||||
}
|
||||
|
||||
inline fun <R> withIC(enabled: Boolean = true, fn: ()->R): R {
|
||||
val isEnabledBackup = IncrementalCompilation.isEnabled()
|
||||
val isEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
||||
IncrementalCompilation.setIsEnabled(enabled)
|
||||
|
||||
try {
|
||||
@@ -114,7 +115,7 @@ class IncrementalJvmCompilerRunner(
|
||||
localStateDirs = localStateDirs
|
||||
) {
|
||||
override fun isICEnabled(): Boolean =
|
||||
IncrementalCompilation.isEnabled()
|
||||
IncrementalCompilation.isEnabledForJvm()
|
||||
|
||||
override fun createCacheManager(args: K2JVMCompilerArguments): IncrementalJvmCachesManager =
|
||||
IncrementalJvmCachesManager(cacheDirectory, File(args.destination), reporter)
|
||||
|
||||
+5
-6
@@ -21,8 +21,8 @@ import java.io.File
|
||||
internal const val STANDALONE_CACHE_VERSION = 2
|
||||
internal const val STANDALONE_VERSION_FILE_NAME = "standalone-ic-format-version.txt"
|
||||
|
||||
fun standaloneCacheVersion(dataRoot: File): CacheVersion =
|
||||
customCacheVersion(STANDALONE_CACHE_VERSION, STANDALONE_VERSION_FILE_NAME, dataRoot, enabled = true)
|
||||
fun standaloneCacheVersion(dataRoot: File, enabled: Boolean): CacheVersion =
|
||||
customCacheVersion(STANDALONE_CACHE_VERSION, STANDALONE_VERSION_FILE_NAME, dataRoot, enabled)
|
||||
|
||||
fun customCacheVersion(version: Int, fileName: String, dataRoot: File, enabled: Boolean): CacheVersion =
|
||||
CacheVersion(ownVersion = version,
|
||||
@@ -30,8 +30,7 @@ fun customCacheVersion(version: Int, fileName: String, dataRoot: File, enabled:
|
||||
whenVersionChanged = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||
whenTurnedOn = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||
whenTurnedOff = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||
isEnabled = { enabled })
|
||||
isEnabled = enabled)
|
||||
|
||||
fun commonCacheVersions(cachesDir: File): List<CacheVersion> =
|
||||
listOf(normalCacheVersion(cachesDir),
|
||||
dataContainerCacheVersion(cachesDir))
|
||||
fun commonCacheVersions(cachesDir: File, enabled: Boolean): List<CacheVersion> =
|
||||
listOf(normalCacheVersion(cachesDir, enabled), dataContainerCacheVersion(cachesDir, enabled))
|
||||
@@ -24,7 +24,7 @@ public class IncrementalCompilation {
|
||||
private static final String INCREMENTAL_COMPILATION_PROPERTY = "kotlin.incremental.compilation";
|
||||
private static final String INCREMENTAL_COMPILATION_JS_PROPERTY = "kotlin.incremental.compilation.js";
|
||||
|
||||
public static boolean isEnabled() {
|
||||
public static boolean isEnabledForJvm() {
|
||||
return "true".equals(System.getProperty(INCREMENTAL_COMPILATION_PROPERTY));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class IncrementalCompilation {
|
||||
}
|
||||
|
||||
public static void toJvmArgs(List<String> jvmArgs) {
|
||||
if (isEnabled()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_PROPERTY);
|
||||
if (isEnabledForJvm()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_PROPERTY);
|
||||
if (isEnabledForJs()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_JS_PROPERTY);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user