Expand compilation scope for IC before backend is run
Sometimes IC raises compilation errors when rebuild succeeds.
This happens because IC uses serialized decriptors
for non-dirty files. Serialized descriptors can be different
from source file descriptors. For example, a source file
may contain an implicit return type or an implicit visibility
for overridden methods, but serialized descriptors always
contain explicit return types & methods' visibilities.
These problems can be solved by expanding a scope of incremental compilation
just after the analysis, but before error reporting & code generation.
In other words, we need to compare descriptors before error reporting and code generation.
If there are new dirty files, current round of IC must be aborted,
next round must be performed with new dirty files.
This commit implements IC scope expansion for JS Klib compiler
#KT-13677
#KT-28233
This commit is contained in:
@@ -83,6 +83,17 @@ open class IncrementalJsCache(
|
||||
dirtySources.addAll(removedAndCompiledSources)
|
||||
}
|
||||
|
||||
fun compare(translatedFiles: Map<File, TranslationResultValue>, changesCollector: ChangesCollector) {
|
||||
for ((srcFile, data) in translatedFiles) {
|
||||
val oldProtoMap = translationResults[srcFile]?.metadata?.let { protoData(srcFile, it) } ?: emptyMap()
|
||||
val newProtoMap = protoData(srcFile, data.metadata)
|
||||
|
||||
for (classId in oldProtoMap.keys + newProtoMap.keys) {
|
||||
changesCollector.collectProtoChanges(oldProtoMap[classId], newProtoMap[classId])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun compareAndUpdate(incrementalResults: IncrementalResultsConsumerImpl, changesCollector: ChangesCollector) {
|
||||
val translatedFiles = incrementalResults.packageParts
|
||||
|
||||
|
||||
@@ -22,11 +22,13 @@ data class BuildLogFinder(
|
||||
private val isDataContainerBuildLogEnabled: Boolean = false,
|
||||
private val isGradleEnabled: Boolean = false,
|
||||
private val isJsEnabled: Boolean = false,
|
||||
private val isJsIrEnabled: Boolean = false // TODO rename as it is used for metadata-only test
|
||||
private val isJsIrEnabled: Boolean = false, // TODO rename as it is used for metadata-only test
|
||||
private val isScopeExpansionEnabled: Boolean = false
|
||||
) {
|
||||
companion object {
|
||||
private const val JS_LOG = "js-build.log"
|
||||
private const val JS_IR_LOG = "js-ir-build.log"
|
||||
private const val SCOPE_EXPANDING_LOG = "build-with-scope-expansion.log"
|
||||
private const val GRADLE_LOG = "gradle-build.log"
|
||||
private const val DATA_CONTAINER_LOG = "data-container-version-build.log"
|
||||
const val JS_JPS_LOG = "js-jps-build.log"
|
||||
@@ -40,6 +42,7 @@ data class BuildLogFinder(
|
||||
val names = dir.list() ?: arrayOf()
|
||||
val files = names.filter { File(dir, it).isFile }.toSet()
|
||||
val matchedName = when {
|
||||
isScopeExpansionEnabled && SCOPE_EXPANDING_LOG in files -> SCOPE_EXPANDING_LOG
|
||||
isJsIrEnabled && JS_IR_LOG in files -> JS_IR_LOG
|
||||
isJsEnabled && JS_LOG in files -> JS_LOG
|
||||
isGradleEnabled && GRADLE_LOG in files -> GRADLE_LOG
|
||||
|
||||
Reference in New Issue
Block a user