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:
@@ -35,9 +35,8 @@ class CacheVersion(
|
|||||||
private val whenVersionChanged: CacheVersion.Action,
|
private val whenVersionChanged: CacheVersion.Action,
|
||||||
private val whenTurnedOn: CacheVersion.Action,
|
private val whenTurnedOn: CacheVersion.Action,
|
||||||
private val whenTurnedOff: CacheVersion.Action,
|
private val whenTurnedOff: CacheVersion.Action,
|
||||||
isEnabled: ()->Boolean
|
private val isEnabled: Boolean
|
||||||
) {
|
) {
|
||||||
private val isEnabled by lazy(isEnabled)
|
|
||||||
|
|
||||||
private val actualVersion: Int?
|
private val actualVersion: Int?
|
||||||
get() = try {
|
get() = try {
|
||||||
@@ -95,18 +94,18 @@ class CacheVersion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun normalCacheVersion(dataRoot: File, enabled: Boolean? = null): CacheVersion =
|
fun normalCacheVersion(dataRoot: File, enabled: Boolean): CacheVersion =
|
||||||
CacheVersion(ownVersion = NORMAL_VERSION,
|
CacheVersion(ownVersion = NORMAL_VERSION,
|
||||||
versionFile = File(dataRoot, NORMAL_VERSION_FILE_NAME),
|
versionFile = File(dataRoot, NORMAL_VERSION_FILE_NAME),
|
||||||
whenVersionChanged = CacheVersion.Action.REBUILD_CHUNK,
|
whenVersionChanged = CacheVersion.Action.REBUILD_CHUNK,
|
||||||
whenTurnedOn = CacheVersion.Action.REBUILD_CHUNK,
|
whenTurnedOn = CacheVersion.Action.REBUILD_CHUNK,
|
||||||
whenTurnedOff = CacheVersion.Action.CLEAN_NORMAL_CACHES,
|
whenTurnedOff = CacheVersion.Action.CLEAN_NORMAL_CACHES,
|
||||||
isEnabled = { enabled ?: IncrementalCompilation.isEnabled() })
|
isEnabled = enabled)
|
||||||
|
|
||||||
fun dataContainerCacheVersion(dataRoot: File, enabled: Boolean? = null): CacheVersion =
|
fun dataContainerCacheVersion(dataRoot: File, enabled: Boolean): CacheVersion =
|
||||||
CacheVersion(ownVersion = DATA_CONTAINER_VERSION,
|
CacheVersion(ownVersion = DATA_CONTAINER_VERSION,
|
||||||
versionFile = File(dataRoot, DATA_CONTAINER_VERSION_FILE_NAME),
|
versionFile = File(dataRoot, DATA_CONTAINER_VERSION_FILE_NAME),
|
||||||
whenVersionChanged = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
whenVersionChanged = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||||
whenTurnedOn = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
whenTurnedOn = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||||
whenTurnedOff = CacheVersion.Action.CLEAN_DATA_CONTAINER,
|
whenTurnedOff = CacheVersion.Action.CLEAN_DATA_CONTAINER,
|
||||||
isEnabled = { enabled ?: IncrementalCompilation.isEnabled() })
|
isEnabled = enabled)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.intellij.util.io.EnumeratorStringDescriptor
|
|||||||
import gnu.trove.THashSet
|
import gnu.trove.THashSet
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.jetbrains.kotlin.build.GeneratedJvmClass
|
import org.jetbrains.kotlin.build.GeneratedJvmClass
|
||||||
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.incremental.storage.*
|
import org.jetbrains.kotlin.incremental.storage.*
|
||||||
import org.jetbrains.kotlin.inline.inlineFunctionsJvmNames
|
import org.jetbrains.kotlin.inline.inlineFunctionsJvmNames
|
||||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||||
@@ -264,7 +265,7 @@ open class IncrementalJvmCache(
|
|||||||
|
|
||||||
override fun clean() {
|
override fun clean() {
|
||||||
super.clean()
|
super.clean()
|
||||||
normalCacheVersion(targetDataRoot).clean()
|
normalCacheVersion(targetDataRoot, IncrementalCompilation.isEnabledForJvm()).clean()
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) {
|
private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class KotlinModuleXmlBuilder {
|
|||||||
directoriesToFilterOut: Set<File>) {
|
directoriesToFilterOut: Set<File>) {
|
||||||
p.println("<!-- Classpath -->")
|
p.println("<!-- Classpath -->")
|
||||||
for (file in files) {
|
for (file in files) {
|
||||||
val isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.isEnabled()
|
val isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.isEnabledForJvm()
|
||||||
if (isOutput) {
|
if (isOutput) {
|
||||||
// For IDEA's make (incremental compilation) purposes, output directories of the current module and its dependencies
|
// For IDEA's make (incremental compilation) purposes, output directories of the current module and its dependencies
|
||||||
// appear on the class path, so we are at risk of seeing the results of the previous build, i.e. if some class was
|
// appear on the class path, so we are at risk of seeing the results of the previous build, i.e. if some class was
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ class MultifileClassCodegenImpl(
|
|||||||
private fun getCompiledPackageFragment(
|
private fun getCompiledPackageFragment(
|
||||||
facadeFqName: FqName, state: GenerationState
|
facadeFqName: FqName, state: GenerationState
|
||||||
): IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment? {
|
): IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment? {
|
||||||
if (!IncrementalCompilation.isEnabled()) return null
|
if (!IncrementalCompilation.isEnabledForJvm()) return null
|
||||||
|
|
||||||
val packageFqName = facadeFqName.parent()
|
val packageFqName = facadeFqName.parent()
|
||||||
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
override fun setupPlatformSpecificArgumentsAndServices(
|
override fun setupPlatformSpecificArgumentsAndServices(
|
||||||
configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments, services: Services
|
configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments, services: Services
|
||||||
) {
|
) {
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
services.get(LookupTracker::class.java)?.let {
|
services.get(LookupTracker::class.java)?.let {
|
||||||
configuration.put(CommonConfigurationKeys.LOOKUP_TRACKER, it)
|
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.K2JVMCompiler
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||||
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.daemon.common.*
|
import org.jetbrains.kotlin.daemon.common.*
|
||||||
import org.jetbrains.kotlin.daemon.report.CompileServicesFacadeMessageCollector
|
import org.jetbrains.kotlin.daemon.report.CompileServicesFacadeMessageCollector
|
||||||
@@ -469,7 +470,7 @@ class CompileServiceImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val workingDir = incrementalCompilationOptions.workingDir
|
val workingDir = incrementalCompilationOptions.workingDir
|
||||||
val versions = commonCacheVersions(workingDir) +
|
val versions = commonCacheVersions(workingDir, enabled = true) +
|
||||||
customCacheVersion(incrementalCompilationOptions.customCacheVersion,
|
customCacheVersion(incrementalCompilationOptions.customCacheVersion,
|
||||||
incrementalCompilationOptions.customCacheVersionFileName,
|
incrementalCompilationOptions.customCacheVersionFileName,
|
||||||
workingDir,
|
workingDir,
|
||||||
@@ -519,7 +520,7 @@ class CompileServiceImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val workingDir = incrementalCompilationOptions.workingDir
|
val workingDir = incrementalCompilationOptions.workingDir
|
||||||
val versions = commonCacheVersions(workingDir) +
|
val versions = commonCacheVersions(workingDir, enabled = true) +
|
||||||
customCacheVersion(incrementalCompilationOptions.customCacheVersion,
|
customCacheVersion(incrementalCompilationOptions.customCacheVersion,
|
||||||
incrementalCompilationOptions.customCacheVersionFileName,
|
incrementalCompilationOptions.customCacheVersionFileName,
|
||||||
workingDir,
|
workingDir,
|
||||||
|
|||||||
+6
-6
@@ -37,7 +37,8 @@ fun makeJsIncrementally(
|
|||||||
messageCollector: MessageCollector = MessageCollector.NONE,
|
messageCollector: MessageCollector = MessageCollector.NONE,
|
||||||
reporter: ICReporter = EmptyICReporter
|
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() }
|
val allKotlinFiles = sourceRoots.asSequence().flatMap { it.walk() }
|
||||||
.filter { it.isFile && it.extension.equals("kt", ignoreCase = true) }.toList()
|
.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()
|
val isJsEnabledBackup = IncrementalCompilation.isEnabledForJs()
|
||||||
IncrementalCompilation.setIsEnabledForJs(true)
|
IncrementalCompilation.setIsEnabledForJs(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return withIC { fn() }
|
return fn()
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
IncrementalCompilation.setIsEnabledForJs(isJsEnabledBackup)
|
IncrementalCompilation.setIsEnabledForJs(isJsEnabledBackup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ class IncrementalJsCompilerRunner(
|
|||||||
reporter
|
reporter
|
||||||
) {
|
) {
|
||||||
override fun isICEnabled(): Boolean =
|
override fun isICEnabled(): Boolean =
|
||||||
IncrementalCompilation.isEnabled() && IncrementalCompilation.isEnabledForJs()
|
IncrementalCompilation.isEnabledForJs()
|
||||||
|
|
||||||
override fun createCacheManager(args: K2JSCompilerArguments): IncrementalJsCachesManager =
|
override fun createCacheManager(args: K2JSCompilerArguments): IncrementalJsCachesManager =
|
||||||
IncrementalJsCachesManager(cacheDirectory, reporter)
|
IncrementalJsCachesManager(cacheDirectory, reporter)
|
||||||
|
|||||||
+4
-3
@@ -56,7 +56,8 @@ fun makeIncrementally(
|
|||||||
messageCollector: MessageCollector = MessageCollector.NONE,
|
messageCollector: MessageCollector = MessageCollector.NONE,
|
||||||
reporter: ICReporter = EmptyICReporter
|
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 kotlinExtensions = listOf("kt", "kts")
|
||||||
val allExtensions = kotlinExtensions + listOf("java")
|
val allExtensions = kotlinExtensions + listOf("java")
|
||||||
@@ -86,7 +87,7 @@ object EmptyICReporter : ICReporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline fun <R> withIC(enabled: Boolean = true, fn: ()->R): R {
|
inline fun <R> withIC(enabled: Boolean = true, fn: ()->R): R {
|
||||||
val isEnabledBackup = IncrementalCompilation.isEnabled()
|
val isEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
||||||
IncrementalCompilation.setIsEnabled(enabled)
|
IncrementalCompilation.setIsEnabled(enabled)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -114,7 +115,7 @@ class IncrementalJvmCompilerRunner(
|
|||||||
localStateDirs = localStateDirs
|
localStateDirs = localStateDirs
|
||||||
) {
|
) {
|
||||||
override fun isICEnabled(): Boolean =
|
override fun isICEnabled(): Boolean =
|
||||||
IncrementalCompilation.isEnabled()
|
IncrementalCompilation.isEnabledForJvm()
|
||||||
|
|
||||||
override fun createCacheManager(args: K2JVMCompilerArguments): IncrementalJvmCachesManager =
|
override fun createCacheManager(args: K2JVMCompilerArguments): IncrementalJvmCachesManager =
|
||||||
IncrementalJvmCachesManager(cacheDirectory, File(args.destination), reporter)
|
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_CACHE_VERSION = 2
|
||||||
internal const val STANDALONE_VERSION_FILE_NAME = "standalone-ic-format-version.txt"
|
internal const val STANDALONE_VERSION_FILE_NAME = "standalone-ic-format-version.txt"
|
||||||
|
|
||||||
fun standaloneCacheVersion(dataRoot: File): CacheVersion =
|
fun standaloneCacheVersion(dataRoot: File, enabled: Boolean): CacheVersion =
|
||||||
customCacheVersion(STANDALONE_CACHE_VERSION, STANDALONE_VERSION_FILE_NAME, dataRoot, enabled = true)
|
customCacheVersion(STANDALONE_CACHE_VERSION, STANDALONE_VERSION_FILE_NAME, dataRoot, enabled)
|
||||||
|
|
||||||
fun customCacheVersion(version: Int, fileName: String, dataRoot: File, enabled: Boolean): CacheVersion =
|
fun customCacheVersion(version: Int, fileName: String, dataRoot: File, enabled: Boolean): CacheVersion =
|
||||||
CacheVersion(ownVersion = version,
|
CacheVersion(ownVersion = version,
|
||||||
@@ -30,8 +30,7 @@ fun customCacheVersion(version: Int, fileName: String, dataRoot: File, enabled:
|
|||||||
whenVersionChanged = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
whenVersionChanged = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||||
whenTurnedOn = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
whenTurnedOn = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||||
whenTurnedOff = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
whenTurnedOff = CacheVersion.Action.REBUILD_ALL_KOTLIN,
|
||||||
isEnabled = { enabled })
|
isEnabled = enabled)
|
||||||
|
|
||||||
fun commonCacheVersions(cachesDir: File): List<CacheVersion> =
|
fun commonCacheVersions(cachesDir: File, enabled: Boolean): List<CacheVersion> =
|
||||||
listOf(normalCacheVersion(cachesDir),
|
listOf(normalCacheVersion(cachesDir, enabled), dataContainerCacheVersion(cachesDir, enabled))
|
||||||
dataContainerCacheVersion(cachesDir))
|
|
||||||
@@ -24,7 +24,7 @@ public class IncrementalCompilation {
|
|||||||
private static final String INCREMENTAL_COMPILATION_PROPERTY = "kotlin.incremental.compilation";
|
private static final String INCREMENTAL_COMPILATION_PROPERTY = "kotlin.incremental.compilation";
|
||||||
private static final String INCREMENTAL_COMPILATION_JS_PROPERTY = "kotlin.incremental.compilation.js";
|
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));
|
return "true".equals(System.getProperty(INCREMENTAL_COMPILATION_PROPERTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class IncrementalCompilation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void toJvmArgs(List<String> jvmArgs) {
|
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);
|
if (isEnabledForJs()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_JS_PROPERTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ abstract class AbstractIncrementalCacheVersionChangedTest : AbstractIncrementalJ
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modifiedFiles.none { it.endsWith("do-not-change-cache-versions") }) {
|
if (modifiedFiles.none { it.endsWith("do-not-change-cache-versions") }) {
|
||||||
val cacheVersionProvider = CacheVersionProvider(paths)
|
val cacheVersionProvider = CacheVersionProvider(paths, isIncrementalCompilationEnabled = true)
|
||||||
val versions = getVersions(cacheVersionProvider, targets)
|
val versions = getVersions(cacheVersionProvider, targets)
|
||||||
val versionFiles = versions.map { it.formatVersionFile }.filter { it.exists() }
|
val versionFiles = versions.map { it.formatVersionFile }.filter { it.exists() }
|
||||||
versionFiles.forEach { it.writeText("777") }
|
versionFiles.forEach { it.writeText("777") }
|
||||||
|
|||||||
+1
-1
@@ -114,7 +114,7 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
lookupsDuringTest = hashSetOf()
|
lookupsDuringTest = hashSetOf()
|
||||||
isICEnabledBackup = IncrementalCompilation.isEnabled()
|
isICEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
||||||
IncrementalCompilation.setIsEnabled(true)
|
IncrementalCompilation.setIsEnabled(true)
|
||||||
|
|
||||||
if (DEBUG_LOGGING_ENABLED) {
|
if (DEBUG_LOGGING_ENABLED) {
|
||||||
|
|||||||
+2
-2
@@ -40,7 +40,7 @@ abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest()
|
|||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
isICEnabledBackup = IncrementalCompilation.isEnabled()
|
isICEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
||||||
IncrementalCompilation.setIsEnabled(true)
|
IncrementalCompilation.setIsEnabled(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest()
|
|||||||
val targets = projectDescriptor.allModuleTargets
|
val targets = projectDescriptor.allModuleTargets
|
||||||
val dataManager = projectDescriptor.dataManager
|
val dataManager = projectDescriptor.dataManager
|
||||||
val paths = dataManager.dataPaths
|
val paths = dataManager.dataPaths
|
||||||
val versions = CacheVersionProvider(paths)
|
val versions = CacheVersionProvider(paths, isIncrementalCompilationEnabled = true)
|
||||||
|
|
||||||
dumpCachesForTarget(p, paths, KotlinDataContainerTarget, versions.dataContainerVersion().formatVersionFile)
|
dumpCachesForTarget(p, paths, KotlinDataContainerTarget, versions.dataContainerVersion().formatVersionFile)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -163,7 +163,7 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
super.setUp()
|
super.setUp()
|
||||||
srcDir = File(workingDir, "src").apply { mkdirs() }
|
srcDir = File(workingDir, "src").apply { mkdirs() }
|
||||||
outDir = File(workingDir, "out")
|
outDir = File(workingDir, "out")
|
||||||
isICEnabledBackup = IncrementalCompilation.isEnabled()
|
isICEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
||||||
IncrementalCompilation.setIsEnabled(true)
|
IncrementalCompilation.setIsEnabled(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYS
|
|||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.incremental.withIC
|
import org.jetbrains.kotlin.incremental.withIC
|
||||||
import org.jetbrains.kotlin.jps.model.JpsKotlinCompilerSettings
|
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.LibraryDependency.*
|
import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.LibraryDependency.*
|
||||||
import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments
|
import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
|
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
|
||||||
@@ -451,7 +450,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
assertFilesExistInOutput(module, "Foo.class", "Bar.class")
|
assertFilesExistInOutput(module, "Foo.class", "Bar.class")
|
||||||
assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
|
assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo")))
|
checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo")))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -470,7 +469,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
assertFilesExistInOutput(module, "Foo.class", "Bar.class")
|
assertFilesExistInOutput(module, "Foo.class", "Bar.class")
|
||||||
assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
|
assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo")))
|
checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo")))
|
||||||
checkWhen(touch("src/dir/subdir/bar.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Bar")))
|
checkWhen(touch("src/dir/subdir/bar.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Bar")))
|
||||||
}
|
}
|
||||||
@@ -491,7 +490,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
assertFilesExistInOutput(module, "Foo.class", "Bar.class")
|
assertFilesExistInOutput(module, "Foo.class", "Bar.class")
|
||||||
assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
|
assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo")))
|
checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo")))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -508,7 +507,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
fun testKotlinProjectTwoFilesInOnePackage() {
|
fun testKotlinProjectTwoFilesInOnePackage() {
|
||||||
doTest()
|
doTest()
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage"))
|
checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage"))
|
||||||
checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage"))
|
checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage"))
|
||||||
}
|
}
|
||||||
@@ -577,7 +576,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
|
|
||||||
result.assertSuccessful()
|
result.assertSuccessful()
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Kt"))
|
checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Kt"))
|
||||||
checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt"))
|
checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt"))
|
||||||
}
|
}
|
||||||
@@ -600,7 +599,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "<clinit>", "b", "getB", "setB")
|
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "<clinit>", "b", "getB", "setB")
|
||||||
|
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage"))
|
checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage"))
|
||||||
checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage"))
|
checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage"))
|
||||||
}
|
}
|
||||||
@@ -622,7 +621,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "<clinit>", "a", "funA", "getA")
|
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "<clinit>", "a", "funA", "getA")
|
||||||
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "<clinit>", "b", "funB", "getB", "setB")
|
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "<clinit>", "b", "funB", "getB", "setB")
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage"))
|
checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage"))
|
||||||
checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage"))
|
checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage"))
|
||||||
}
|
}
|
||||||
@@ -903,7 +902,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
initProject(JVM_MOCK_RUNTIME)
|
initProject(JVM_MOCK_RUNTIME)
|
||||||
buildAllModules().assertSuccessful()
|
buildAllModules().assertSuccessful()
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (IncrementalCompilation.isEnabledForJvm()) {
|
||||||
checkWhen(touch("src/utils.kt"), null, packageClasses("kotlinProject", "src/utils.kt", "_DefaultPackage"))
|
checkWhen(touch("src/utils.kt"), null, packageClasses("kotlinProject", "src/utils.kt", "_DefaultPackage"))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+1
-2
@@ -22,7 +22,6 @@ import org.jetbrains.jps.builders.JpsBuildTestCase
|
|||||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
import org.jetbrains.kotlin.jps.model.JpsKotlinCompilerSettings
|
|
||||||
import kotlin.reflect.KMutableProperty1
|
import kotlin.reflect.KMutableProperty1
|
||||||
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS
|
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS
|
||||||
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_ENABLED_PROPERTY
|
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_ENABLED_PROPERTY
|
||||||
@@ -36,7 +35,7 @@ class KotlinJpsBuildTestIncremental : KotlinJpsBuildTest() {
|
|||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
isICEnabledBackup = IncrementalCompilation.isEnabled()
|
isICEnabledBackup = IncrementalCompilation.isEnabledForJvm()
|
||||||
IncrementalCompilation.setIsEnabled(true)
|
IncrementalCompilation.setIsEnabled(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import org.jetbrains.jps.model.java.JpsJavaClasspathKind
|
|||||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||||
import org.jetbrains.jps.model.module.JpsModule
|
import org.jetbrains.jps.model.module.JpsModule
|
||||||
import org.jetbrains.kotlin.build.GeneratedFile
|
import org.jetbrains.kotlin.build.GeneratedFile
|
||||||
import org.jetbrains.kotlin.build.JvmBuildMetaInfo
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
|
||||||
@@ -88,7 +87,8 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|
|
||||||
override fun buildStarted(context: CompileContext) {
|
override fun buildStarted(context: CompileContext) {
|
||||||
LOG.debug("==========================================")
|
LOG.debug("==========================================")
|
||||||
LOG.info("is Kotlin incremental compilation enabled: ${IncrementalCompilation.isEnabled()}")
|
LOG.info("is Kotlin incremental compilation enabled for JVM: ${IncrementalCompilation.isEnabledForJvm()}")
|
||||||
|
LOG.info("is Kotlin incremental compilation enabled for JS: ${IncrementalCompilation.isEnabledForJs()}")
|
||||||
LOG.info("is Kotlin compiler daemon enabled: ${isDaemonEnabled()}")
|
LOG.info("is Kotlin compiler daemon enabled: ${isDaemonEnabled()}")
|
||||||
|
|
||||||
val historyLabel = context.getBuilderParameter("history label")
|
val historyLabel = context.getBuilderParameter("history label")
|
||||||
@@ -128,8 +128,13 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
)
|
)
|
||||||
val fsOperations = FSOperationsHelper(context, chunk, roundDirtyFiles, LOG)
|
val fsOperations = FSOperationsHelper(context, chunk, roundDirtyFiles, LOG)
|
||||||
|
|
||||||
if (System.getProperty(SKIP_CACHE_VERSION_CHECK_PROPERTY) == null) {
|
val jpsRepresentativeTarget = chunk.representativeTarget()
|
||||||
val cacheVersionsProvider = CacheVersionProvider(dataManager.dataPaths)
|
val representativeTarget = context.kotlinBuildTargets[jpsRepresentativeTarget]
|
||||||
|
if (representativeTarget == null) {
|
||||||
|
LOG.warn("Unable to find Kotlin build target for JPS target ${jpsRepresentativeTarget.presentableName}")
|
||||||
|
}
|
||||||
|
if (System.getProperty(SKIP_CACHE_VERSION_CHECK_PROPERTY) == null && representativeTarget != null) {
|
||||||
|
val cacheVersionsProvider = CacheVersionProvider(dataManager.dataPaths, representativeTarget.isIncrementalCompilationEnabled)
|
||||||
val actions = checkCachesVersions(context, cacheVersionsProvider, chunk)
|
val actions = checkCachesVersions(context, cacheVersionsProvider, chunk)
|
||||||
applyActionsOnCacheVersionChange(actions, cacheVersionsProvider, context, dataManager, targets, fsOperations)
|
applyActionsOnCacheVersionChange(actions, cacheVersionsProvider, context, dataManager, targets, fsOperations)
|
||||||
if (CacheVersion.Action.REBUILD_ALL_KOTLIN in actions) {
|
if (CacheVersion.Action.REBUILD_ALL_KOTLIN in actions) {
|
||||||
@@ -280,7 +285,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|| targets.any { rebuildAfterCacheVersionChanged[it] == true }
|
|| targets.any { rebuildAfterCacheVersionChanged[it] == true }
|
||||||
|
|
||||||
if (kotlinDirtyFilesHolder.hasDirtyOrRemovedFiles) {
|
if (kotlinDirtyFilesHolder.hasDirtyOrRemovedFiles) {
|
||||||
if (!isChunkRebuilding && !IncrementalCompilation.isEnabled()) {
|
if (!isChunkRebuilding && !representativeTarget.isIncrementalCompilationEnabled) {
|
||||||
targets.forEach { rebuildAfterCacheVersionChanged[it] = true }
|
targets.forEach { rebuildAfterCacheVersionChanged[it] = true }
|
||||||
return CHUNK_REBUILD_REQUIRED
|
return CHUNK_REBUILD_REQUIRED
|
||||||
}
|
}
|
||||||
@@ -300,7 +305,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val project = projectDescriptor.project
|
val project = projectDescriptor.project
|
||||||
val lookupTracker = getLookupTracker(project)
|
val lookupTracker = getLookupTracker(project, representativeTarget)
|
||||||
val exceptActualTracer = ExpectActualTrackerImpl()
|
val exceptActualTracer = ExpectActualTrackerImpl()
|
||||||
val incrementalCaches = getIncrementalCaches(chunk, context)
|
val incrementalCaches = getIncrementalCaches(chunk, context)
|
||||||
val environment = createCompileEnvironment(
|
val environment = createCompileEnvironment(
|
||||||
@@ -366,7 +371,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
incrementalCaches
|
incrementalCaches
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!IncrementalCompilation.isEnabled()) {
|
if (!representativeTarget.isIncrementalCompilationEnabled) {
|
||||||
return OK
|
return OK
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,7 +482,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|
|
||||||
private fun doCompileModuleChunk(
|
private fun doCompileModuleChunk(
|
||||||
chunk: ModuleChunk,
|
chunk: ModuleChunk,
|
||||||
kotlinTarget: KotlinModuleBuildTarget<*>,
|
representativeTarget: KotlinModuleBuildTarget<*>,
|
||||||
commonArguments: CommonCompilerArguments,
|
commonArguments: CommonCompilerArguments,
|
||||||
context: CompileContext,
|
context: CompileContext,
|
||||||
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
||||||
@@ -486,26 +491,25 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
incrementalCaches: Map<ModuleBuildTarget, JpsIncrementalCache>
|
incrementalCaches: Map<ModuleBuildTarget, JpsIncrementalCache>
|
||||||
): OutputItemsCollector? {
|
): OutputItemsCollector? {
|
||||||
|
|
||||||
val representativeTarget = chunk.representativeTarget()
|
|
||||||
|
|
||||||
fun concatenate(strings: Array<String>?, cp: List<String>) = arrayOf(*strings.orEmpty(), *cp.toTypedArray())
|
fun concatenate(strings: Array<String>?, cp: List<String>) = arrayOf(*strings.orEmpty(), *cp.toTypedArray())
|
||||||
|
|
||||||
for (argumentProvider in ServiceLoader.load(KotlinJpsCompilerArgumentsProvider::class.java)) {
|
for (argumentProvider in ServiceLoader.load(KotlinJpsCompilerArgumentsProvider::class.java)) {
|
||||||
|
val jpsModuleBuildTarget = representativeTarget.jpsModuleBuildTarget
|
||||||
// appending to pluginOptions
|
// appending to pluginOptions
|
||||||
commonArguments.pluginOptions = concatenate(
|
commonArguments.pluginOptions = concatenate(
|
||||||
commonArguments.pluginOptions,
|
commonArguments.pluginOptions,
|
||||||
argumentProvider.getExtraArguments(representativeTarget, context)
|
argumentProvider.getExtraArguments(jpsModuleBuildTarget, context)
|
||||||
)
|
)
|
||||||
// appending to classpath
|
// appending to classpath
|
||||||
commonArguments.pluginClasspaths = concatenate(
|
commonArguments.pluginClasspaths = concatenate(
|
||||||
commonArguments.pluginClasspaths,
|
commonArguments.pluginClasspaths,
|
||||||
argumentProvider.getClasspath(representativeTarget, context)
|
argumentProvider.getClasspath(jpsModuleBuildTarget, context)
|
||||||
)
|
)
|
||||||
|
|
||||||
LOG.debug("Plugin loaded: ${argumentProvider::class.java.simpleName}")
|
LOG.debug("Plugin loaded: ${argumentProvider::class.java.simpleName}")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) {
|
if (representativeTarget.isIncrementalCompilationEnabled) {
|
||||||
for (target in chunk.targets) {
|
for (target in chunk.targets) {
|
||||||
val cache = incrementalCaches[target]
|
val cache = incrementalCaches[target]
|
||||||
val targetDirtyFiles = dirtyFilesHolder.byTarget[target]
|
val targetDirtyFiles = dirtyFilesHolder.byTarget[target]
|
||||||
@@ -519,7 +523,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val isDoneSomething = kotlinTarget.compileModuleChunk(chunk, commonArguments, dirtyFilesHolder, environment)
|
val isDoneSomething = representativeTarget.compileModuleChunk(chunk, commonArguments, dirtyFilesHolder, environment)
|
||||||
|
|
||||||
return if (isDoneSomething) environment.outputItemsCollector else null
|
return if (isDoneSomething) environment.outputItemsCollector else null
|
||||||
}
|
}
|
||||||
@@ -663,10 +667,10 @@ private fun ChangesCollector.getDirtyFiles(
|
|||||||
return dirtyFilesFromLookups + mapClassesFqNamesToFiles(caches, dirtyClassFqNames, reporter)
|
return dirtyFilesFromLookups + mapClassesFqNamesToFiles(caches, dirtyClassFqNames, reporter)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLookupTracker(project: JpsProject): LookupTracker {
|
private fun getLookupTracker(project: JpsProject, representativeTarget: KotlinModuleBuildTarget<*>): LookupTracker {
|
||||||
val testLookupTracker = project.testingContext?.lookupTracker ?: LookupTracker.DO_NOTHING
|
val testLookupTracker = project.testingContext?.lookupTracker ?: LookupTracker.DO_NOTHING
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled()) return LookupTrackerImpl(testLookupTracker)
|
if (representativeTarget.isIncrementalCompilationEnabled) return LookupTrackerImpl(testLookupTracker)
|
||||||
|
|
||||||
return testLookupTracker
|
return testLookupTracker
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,20 +25,23 @@ import org.jetbrains.kotlin.incremental.normalCacheVersion
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class CacheVersionProvider(private val paths: BuildDataPaths) {
|
class CacheVersionProvider(
|
||||||
|
private val paths: BuildDataPaths,
|
||||||
|
private val isIncrementalCompilationEnabled: Boolean
|
||||||
|
) {
|
||||||
private val BuildTarget<*>.dataRoot: File
|
private val BuildTarget<*>.dataRoot: File
|
||||||
get() = paths.getTargetDataRoot(this)
|
get() = paths.getTargetDataRoot(this)
|
||||||
|
|
||||||
fun normalVersion(target: ModuleBuildTarget): CacheVersion = normalCacheVersion(target.dataRoot)
|
fun normalVersion(target: ModuleBuildTarget): CacheVersion = normalCacheVersion(target.dataRoot, isIncrementalCompilationEnabled)
|
||||||
|
|
||||||
fun dataContainerVersion(): CacheVersion = dataContainerCacheVersion(KotlinDataContainerTarget.dataRoot)
|
fun dataContainerVersion(): CacheVersion = dataContainerCacheVersion(KotlinDataContainerTarget.dataRoot, isIncrementalCompilationEnabled)
|
||||||
|
|
||||||
fun allVersions(targets: Iterable<ModuleBuildTarget>): Iterable<CacheVersion> {
|
fun allVersions(targets: Iterable<ModuleBuildTarget>): Iterable<CacheVersion> {
|
||||||
val versions = arrayListOf<CacheVersion>()
|
val versions = arrayListOf<CacheVersion>()
|
||||||
versions.add(dataContainerCacheVersion(KotlinDataContainerTarget.dataRoot))
|
versions.add(dataContainerCacheVersion(KotlinDataContainerTarget.dataRoot, isIncrementalCompilationEnabled))
|
||||||
|
|
||||||
for (dataRoot in targets.map { it.dataRoot }) {
|
for (dataRoot in targets.map { it.dataRoot }) {
|
||||||
versions.add(normalCacheVersion(dataRoot))
|
versions.add(normalCacheVersion(dataRoot, isIncrementalCompilationEnabled))
|
||||||
}
|
}
|
||||||
|
|
||||||
return versions
|
return versions
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||||
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||||
import org.jetbrains.kotlin.jps.model.k2MetadataCompilerArguments
|
import org.jetbrains.kotlin.jps.model.k2MetadataCompilerArguments
|
||||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings
|
import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings
|
||||||
@@ -26,6 +27,9 @@ private const val COMMON_BUILD_META_INFO_FILE_NAME = "common-build-meta-info.txt
|
|||||||
class KotlinCommonModuleBuildTarget(context: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
class KotlinCommonModuleBuildTarget(context: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
||||||
KotlinModuleBuildTarget<CommonBuildMetaInfo>(context, jpsModuleBuildTarget) {
|
KotlinModuleBuildTarget<CommonBuildMetaInfo>(context, jpsModuleBuildTarget) {
|
||||||
|
|
||||||
|
override val isIncrementalCompilationEnabled: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
override val buildMetaInfoFactory
|
override val buildMetaInfoFactory
|
||||||
get() = CommonBuildMetaInfo
|
get() = CommonBuildMetaInfo
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ private const val JS_BUILD_META_INFO_FILE_NAME = "js-build-meta-info.txt"
|
|||||||
class KotlinJsModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
class KotlinJsModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
||||||
KotlinModuleBuildTarget<JsBuildMetaInfo>(compileContext, jpsModuleBuildTarget) {
|
KotlinModuleBuildTarget<JsBuildMetaInfo>(compileContext, jpsModuleBuildTarget) {
|
||||||
|
|
||||||
|
override val isIncrementalCompilationEnabled: Boolean
|
||||||
|
get() = IncrementalCompilation.isEnabledForJs()
|
||||||
|
|
||||||
override val buildMetaInfoFactory
|
override val buildMetaInfoFactory
|
||||||
get() = JsBuildMetaInfo
|
get() = JsBuildMetaInfo
|
||||||
|
|
||||||
@@ -68,7 +71,7 @@ class KotlinJsModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTa
|
|||||||
with(builder) {
|
with(builder) {
|
||||||
register(IncrementalResultsConsumer::class.java, IncrementalResultsConsumerImpl())
|
register(IncrementalResultsConsumer::class.java, IncrementalResultsConsumerImpl())
|
||||||
|
|
||||||
if (IncrementalCompilation.isEnabled() && !isFirstBuild) {
|
if (isIncrementalCompilationEnabled && !isFirstBuild) {
|
||||||
val cache = incrementalCaches[jpsModuleBuildTarget] as IncrementalJsCache
|
val cache = incrementalCaches[jpsModuleBuildTarget] as IncrementalJsCache
|
||||||
|
|
||||||
register(
|
register(
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||||
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.incremental.ChangesCollector
|
import org.jetbrains.kotlin.incremental.ChangesCollector
|
||||||
import org.jetbrains.kotlin.incremental.IncrementalCompilationComponentsImpl
|
import org.jetbrains.kotlin.incremental.IncrementalCompilationComponentsImpl
|
||||||
@@ -53,6 +54,9 @@ private const val JVM_BUILD_META_INFO_FILE_NAME = "jvm-build-meta-info.txt"
|
|||||||
class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
||||||
KotlinModuleBuildTarget<JvmBuildMetaInfo>(compileContext, jpsModuleBuildTarget) {
|
KotlinModuleBuildTarget<JvmBuildMetaInfo>(compileContext, jpsModuleBuildTarget) {
|
||||||
|
|
||||||
|
override val isIncrementalCompilationEnabled: Boolean
|
||||||
|
get() = IncrementalCompilation.isEnabledForJvm()
|
||||||
|
|
||||||
override fun createCacheStorage(paths: BuildDataPaths) = JpsIncrementalJvmCache(jpsModuleBuildTarget, paths)
|
override fun createCacheStorage(paths: BuildDataPaths) = JpsIncrementalJvmCache(jpsModuleBuildTarget, paths)
|
||||||
|
|
||||||
override val buildMetaInfoFactory
|
override val buildMetaInfoFactory
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.config.Services
|
|||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||||
import org.jetbrains.kotlin.incremental.ChangesCollector
|
import org.jetbrains.kotlin.incremental.ChangesCollector
|
||||||
import org.jetbrains.kotlin.incremental.ExpectActualTrackerImpl
|
import org.jetbrains.kotlin.incremental.ExpectActualTrackerImpl
|
||||||
|
import org.jetbrains.kotlin.incremental.LookupTrackerImpl
|
||||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
@@ -52,6 +53,8 @@ abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo>(
|
|||||||
val context: CompileContext,
|
val context: CompileContext,
|
||||||
val jpsModuleBuildTarget: ModuleBuildTarget
|
val jpsModuleBuildTarget: ModuleBuildTarget
|
||||||
) {
|
) {
|
||||||
|
abstract val isIncrementalCompilationEnabled: Boolean
|
||||||
|
|
||||||
val module: JpsModule
|
val module: JpsModule
|
||||||
get() = jpsModuleBuildTarget.module
|
get() = jpsModuleBuildTarget.module
|
||||||
|
|
||||||
@@ -241,8 +244,10 @@ abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo>(
|
|||||||
// Should not be cached since may be vary in different rounds
|
// Should not be cached since may be vary in different rounds
|
||||||
|
|
||||||
val jpsModuleTarget = target.jpsModuleBuildTarget
|
val jpsModuleTarget = target.jpsModuleBuildTarget
|
||||||
return if (IncrementalCompilation.isEnabled()) dirtyFilesHolder.getDirtyFiles(jpsModuleTarget)
|
return when {
|
||||||
else target.sourceFiles
|
isIncrementalCompilationEnabled -> dirtyFilesHolder.getDirtyFiles(jpsModuleTarget)
|
||||||
|
else -> target.sourceFiles
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun checkShouldCompileAndLog(dirtyFilesHolder: KotlinDirtySourceFilesHolder, moduleSources: Collection<File>) =
|
protected fun checkShouldCompileAndLog(dirtyFilesHolder: KotlinDirtySourceFilesHolder, moduleSources: Collection<File>) =
|
||||||
@@ -278,7 +283,7 @@ abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo>(
|
|||||||
fun saveVersions(context: CompileContext, chunk: ModuleChunk, commonArguments: CommonCompilerArguments) {
|
fun saveVersions(context: CompileContext, chunk: ModuleChunk, commonArguments: CommonCompilerArguments) {
|
||||||
val dataManager = context.projectDescriptor.dataManager
|
val dataManager = context.projectDescriptor.dataManager
|
||||||
val targets = chunk.targets
|
val targets = chunk.targets
|
||||||
val cacheVersionsProvider = CacheVersionProvider(dataManager.dataPaths)
|
val cacheVersionsProvider = CacheVersionProvider(dataManager.dataPaths, isIncrementalCompilationEnabled)
|
||||||
cacheVersionsProvider.allVersions(targets).forEach { it.saveIfNeeded() }
|
cacheVersionsProvider.allVersions(targets).forEach { it.saveIfNeeded() }
|
||||||
|
|
||||||
val buildMetaInfo = buildMetaInfoFactory.create(commonArguments)
|
val buildMetaInfo = buildMetaInfoFactory.create(commonArguments)
|
||||||
|
|||||||
Reference in New Issue
Block a user