diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index dfc7afb28c8..b2b6cf1d9ea 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -201,18 +201,21 @@ class K2JsIrCompiler : CLICompiler() { } val start = System.currentTimeMillis() - buildCache( - cachePath = outputFilePath, - project = projectJs, - mainModule = mainModule, - analyzer = AnalyzerWithCompilerReport(config.configuration), - configuration = config.configuration, - dependencies = libraries, - friendDependencies = friendLibraries, - icCache = checkCaches(libraries, icCaches, skipLib = mainModule.libPath) - ) - - messageCollector.report(INFO, "IC cache building duration: ${System.currentTimeMillis() - start}ms") + if (buildCache( + cachePath = outputFilePath, + project = projectJs, + mainModule = mainModule, + analyzer = AnalyzerWithCompilerReport(config.configuration), + configuration = config.configuration, + dependencies = libraries, + friendDependencies = friendLibraries, + icCache = checkCaches(libraries, icCaches, skipLib = mainModule.libPath) + ) + ) { + messageCollector.report(INFO, "IC cache building duration: ${System.currentTimeMillis() - start}ms") + } else { + messageCollector.report(INFO, "IC cache up-to-date check duration: ${System.currentTimeMillis() - start}ms") + } return OK } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/fileUtil.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/fileUtil.kt index 21dd072e62a..7f7edaed81a 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/fileUtil.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/fileUtil.kt @@ -21,6 +21,7 @@ import kotlin.random.nextULong private val compilerVersion = Random.nextULong() // TODO more parameters for lowerings +// Returns true if caches were built. False if caches were up-to-date. fun buildCache( cachePath: String, project: Project, @@ -32,7 +33,7 @@ fun buildCache( exportedDeclarations: Set = emptySet(), forceClean: Boolean = false, icCache: IcCacheInfo = IcCacheInfo.EMPTY, -) { +): Boolean { val dependencyHashes = dependencies.mapNotNull { val path = File(it).canonicalPath icCache.md5[path] @@ -42,7 +43,7 @@ fun buildCache( if (!forceClean) { val oldCacheInfo = CacheInfo.load(cachePath) - if (oldCacheInfo != null && md5 == oldCacheInfo.md5) return + if (oldCacheInfo != null && md5 == oldCacheInfo.md5) return false } val icDir = File(cachePath) @@ -54,6 +55,8 @@ fun buildCache( icData.writeTo(File(cachePath)) CacheInfo(cachePath, mainModule.libPath, md5).save() + + return true } private fun File.md5(additional: Iterable = emptyList()): ULong {