[K/JS] Implement an incremental compilation for the per-file granularity
This commit is contained in:
@@ -6,13 +6,27 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.ir.backend.js.ic.DirtyFileState
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsGenerationGranularity
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class ProjectInfo(val name: String, val modules: List<String>, val steps: List<ProjectBuildStep>, val muted: Boolean, val moduleKind: ModuleKind) {
|
||||
class ProjectInfo(
|
||||
val name: String,
|
||||
val modules: List<String>,
|
||||
val steps: List<ProjectBuildStep>,
|
||||
val muted: Boolean,
|
||||
val moduleKind: ModuleKind,
|
||||
val ignoredGranularities: Set<JsGenerationGranularity>
|
||||
) {
|
||||
|
||||
class ProjectBuildStep(val id: Int, val order: List<String>, val dirtyJS: List<String>, val language: List<String>)
|
||||
class ProjectBuildStep(
|
||||
val id: Int,
|
||||
val order: List<String>,
|
||||
val dirtyJsFiles: List<String>,
|
||||
val dirtyJsModules: List<String>,
|
||||
val language: List<String>,
|
||||
)
|
||||
}
|
||||
|
||||
class ModuleInfo(val moduleName: String) {
|
||||
@@ -60,8 +74,11 @@ const val PROJECT_INFO_FILE = "project.info"
|
||||
private const val MODULES_LIST = "MODULES"
|
||||
private const val MODULES_KIND = "MODULE_KIND"
|
||||
private const val LIBS_LIST = "libs"
|
||||
private const val DIRTY_JS_MODULES_LIST = "dirty js"
|
||||
private const val DIRTY_JS_FILES_LIST = "dirty js files"
|
||||
private const val DIRTY_JS_MODULES_LIST = "dirty js modules"
|
||||
private const val LANGUAGE = "language"
|
||||
private const val IGNORE_PER_FILE = "IGNORE_PER_FILE"
|
||||
private const val IGNORE_PER_MODULE = "IGNORE_PER_MODULE"
|
||||
|
||||
const val MODULE_INFO_FILE = "module.info"
|
||||
private const val DEPENDENCIES = "dependencies"
|
||||
@@ -119,7 +136,8 @@ class ProjectInfoParser(infoFile: File) : InfoParser<ProjectInfo>(infoFile) {
|
||||
|
||||
private fun parseSteps(firstId: Int, lastId: Int): List<ProjectInfo.ProjectBuildStep> {
|
||||
val order = mutableListOf<String>()
|
||||
val dirtyJS = mutableListOf<String>()
|
||||
val dirtyJsFiles = mutableListOf<String>()
|
||||
val dirtyJsModules = mutableListOf<String>()
|
||||
val language = mutableListOf<String>()
|
||||
|
||||
loop { line ->
|
||||
@@ -138,7 +156,8 @@ class ProjectInfoParser(infoFile: File) : InfoParser<ProjectInfo>(infoFile) {
|
||||
|
||||
when (op) {
|
||||
LIBS_LIST -> order += split[1].splitAndTrim()
|
||||
DIRTY_JS_MODULES_LIST -> dirtyJS += split[1].splitAndTrim()
|
||||
DIRTY_JS_FILES_LIST -> dirtyJsFiles += split[1].splitAndTrim()
|
||||
DIRTY_JS_MODULES_LIST -> dirtyJsModules += split[1].splitAndTrim()
|
||||
LANGUAGE -> language += split[1].splitAndTrim()
|
||||
else -> println(diagnosticMessage("Unknown op $op", line))
|
||||
}
|
||||
@@ -146,12 +165,13 @@ class ProjectInfoParser(infoFile: File) : InfoParser<ProjectInfo>(infoFile) {
|
||||
false
|
||||
}
|
||||
|
||||
return (firstId..lastId).map { ProjectInfo.ProjectBuildStep(it, order, dirtyJS, language) }
|
||||
return (firstId..lastId).map { ProjectInfo.ProjectBuildStep(it, order, dirtyJsFiles, dirtyJsModules, language) }
|
||||
}
|
||||
|
||||
override fun parse(entryName: String): ProjectInfo {
|
||||
val libraries = mutableListOf<String>()
|
||||
val steps = mutableListOf<ProjectInfo.ProjectBuildStep>()
|
||||
val ignoredGranularities = mutableSetOf<JsGenerationGranularity>()
|
||||
var muted = false
|
||||
var moduleKind = ModuleKind.ES
|
||||
|
||||
@@ -171,6 +191,8 @@ class ProjectInfoParser(infoFile: File) : InfoParser<ProjectInfo>(infoFile) {
|
||||
|
||||
when {
|
||||
op == MODULES_LIST -> libraries += split[1].splitAndTrim()
|
||||
op == IGNORE_PER_FILE && split[1].trim() == "true" -> ignoredGranularities += JsGenerationGranularity.PER_FILE
|
||||
op == IGNORE_PER_MODULE && split[1].trim() == "true" -> ignoredGranularities += JsGenerationGranularity.PER_MODULE
|
||||
op == MODULES_KIND -> moduleKind = split[1].trim()
|
||||
.ifEmpty { error("Module kind value should be provided if MODULE_KIND pragma was specified") }
|
||||
.let { moduleKindMap[it] ?: error("Unknown MODULE_KIND value '$it'") }
|
||||
@@ -200,7 +222,7 @@ class ProjectInfoParser(infoFile: File) : InfoParser<ProjectInfo>(infoFile) {
|
||||
false
|
||||
}
|
||||
|
||||
return ProjectInfo(entryName, libraries, steps, muted, moduleKind)
|
||||
return ProjectInfo(entryName, libraries, steps, muted, moduleKind, ignoredGranularities)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user