[JS IR] Delegate invalidated files processing to the caller
This change is needed to test invalidation somehow
This commit is contained in:
committed by
TeamCityServer
parent
5b1ec561a9
commit
a01d9b77c3
@@ -219,7 +219,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
|||||||
val start = System.currentTimeMillis()
|
val start = System.currentTimeMillis()
|
||||||
|
|
||||||
val updated = if (perFileCache) {
|
val updated = if (perFileCache) {
|
||||||
actualizeCacheForModule(includes, outputFilePath, configurationJs, libraries, icCaches, IrFactoryImpl)
|
actualizeCacheForModule(includes, outputFilePath, configurationJs, libraries, icCaches, IrFactoryImpl, ::buildCacheForModuleFiles)
|
||||||
} else {
|
} else {
|
||||||
buildCache(
|
buildCache(
|
||||||
cachePath = outputFilePath,
|
cachePath = outputFilePath,
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ private fun buildCacheForModule(
|
|||||||
cleanInlineHashes: Map<IdSignature, Hash>,
|
cleanInlineHashes: Map<IdSignature, Hash>,
|
||||||
cacheConsumer: PersistentCacheConsumer,
|
cacheConsumer: PersistentCacheConsumer,
|
||||||
signatureDeserializers: Map<FilePath, Map<IdSignature, Int>>,
|
signatureDeserializers: Map<FilePath, Map<IdSignature, Int>>,
|
||||||
fileFingerPrints: Map<String, Hash>
|
fileFingerPrints: Map<String, Hash>,
|
||||||
|
cacheExecutor: CacheExecutor
|
||||||
) {
|
) {
|
||||||
val dirtyIrFiles = irModule.files.filter { it.fileEntry.name in dirtyFiles }
|
val dirtyIrFiles = irModule.files.filter { it.fileEntry.name in dirtyFiles }
|
||||||
|
|
||||||
@@ -191,7 +192,8 @@ private fun buildCacheForModule(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: actual way of building a cache could change in future
|
// TODO: actual way of building a cache could change in future
|
||||||
buildCacheForModuleFiles(irModule, dependencies, deserializer, configuration, dirtyFiles, cacheConsumer, emptySet(), null) // TODO: main arguments?
|
|
||||||
|
cacheExecutor.execute(irModule, dependencies, deserializer, configuration, dirtyFiles, cacheConsumer, emptySet(), null) // TODO: main arguments?
|
||||||
|
|
||||||
cacheConsumer.commitLibraryPath(libraryPath)
|
cacheConsumer.commitLibraryPath(libraryPath)
|
||||||
}
|
}
|
||||||
@@ -288,6 +290,20 @@ typealias ModuleName = String
|
|||||||
typealias ModulePath = String
|
typealias ModulePath = String
|
||||||
typealias FilePath = String
|
typealias FilePath = String
|
||||||
|
|
||||||
|
|
||||||
|
fun interface CacheExecutor {
|
||||||
|
fun execute(
|
||||||
|
currentModule: IrModuleFragment,
|
||||||
|
dependencies: Collection<IrModuleFragment>,
|
||||||
|
deserializer: JsIrLinker,
|
||||||
|
configuration: CompilerConfiguration,
|
||||||
|
dirtyFiles: Collection<String>?, // if null consider the whole module dirty
|
||||||
|
cacheConsumer: PersistentCacheConsumer,
|
||||||
|
exportedDeclarations: Set<FqName>,
|
||||||
|
mainArguments: List<String>?,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun actualizeCacheForModule(
|
fun actualizeCacheForModule(
|
||||||
moduleName: String,
|
moduleName: String,
|
||||||
cachePath: String,
|
cachePath: String,
|
||||||
@@ -295,6 +311,7 @@ fun actualizeCacheForModule(
|
|||||||
dependencies: Collection<ModulePath>,
|
dependencies: Collection<ModulePath>,
|
||||||
icCachePaths: Collection<String>,
|
icCachePaths: Collection<String>,
|
||||||
irFactory: IrFactory,
|
irFactory: IrFactory,
|
||||||
|
executor: CacheExecutor
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val icCacheMap: Map<ModulePath, String> = loadCacheInfo(icCachePaths).also {
|
val icCacheMap: Map<ModulePath, String> = loadCacheInfo(icCachePaths).also {
|
||||||
it[moduleName.toCanonicalPath()] = cachePath
|
it[moduleName.toCanonicalPath()] = cachePath
|
||||||
@@ -317,7 +334,7 @@ fun actualizeCacheForModule(
|
|||||||
val currentModule = libraries[moduleName.toCanonicalPath()] ?: error("No loaded library found for path $moduleName")
|
val currentModule = libraries[moduleName.toCanonicalPath()] ?: error("No loaded library found for path $moduleName")
|
||||||
val persistentCacheConsumer = createCacheConsumer(cachePath)
|
val persistentCacheConsumer = createCacheConsumer(cachePath)
|
||||||
|
|
||||||
return actualizeCacheForModule(currentModule, compilerConfiguration, dependencyGraph, persistentCacheProviders, persistentCacheConsumer, irFactory)
|
return actualizeCacheForModule(currentModule, compilerConfiguration, dependencyGraph, persistentCacheProviders, persistentCacheConsumer, irFactory, executor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -328,6 +345,7 @@ private fun actualizeCacheForModule(
|
|||||||
persistentCacheProviders: Map<KotlinLibrary, PersistentCacheProvider>,
|
persistentCacheProviders: Map<KotlinLibrary, PersistentCacheProvider>,
|
||||||
persistentCacheConsumer: PersistentCacheConsumer,
|
persistentCacheConsumer: PersistentCacheConsumer,
|
||||||
irFactory: IrFactory,
|
irFactory: IrFactory,
|
||||||
|
cacheExecutor: CacheExecutor
|
||||||
): Boolean {
|
): Boolean {
|
||||||
// 1. Invalidate
|
// 1. Invalidate
|
||||||
val dependencies = dependencyGraph[library]!!
|
val dependencies = dependencyGraph[library]!!
|
||||||
@@ -422,7 +440,8 @@ private fun actualizeCacheForModule(
|
|||||||
sigHashes,
|
sigHashes,
|
||||||
persistentCacheConsumer,
|
persistentCacheConsumer,
|
||||||
deserializers,
|
deserializers,
|
||||||
fileFingerPrints
|
fileFingerPrints,
|
||||||
|
cacheExecutor
|
||||||
)
|
)
|
||||||
return false // invalidated and re-built
|
return false // invalidated and re-built
|
||||||
}
|
}
|
||||||
@@ -477,7 +496,7 @@ fun rebuildCacheForDirtyFiles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
private fun buildCacheForModuleFiles(
|
fun buildCacheForModuleFiles(
|
||||||
currentModule: IrModuleFragment,
|
currentModule: IrModuleFragment,
|
||||||
dependencies: Collection<IrModuleFragment>,
|
dependencies: Collection<IrModuleFragment>,
|
||||||
deserializer: JsIrLinker,
|
deserializer: JsIrLinker,
|
||||||
|
|||||||
Reference in New Issue
Block a user