Optimize platform libraries build by sharing module cache (#3052)
Was disabled with #2831.
This commit is contained in:
committed by
GitHub
parent
5308997f6f
commit
084be21d89
+13
-4
@@ -33,13 +33,22 @@ private fun buildModulesInfo(index: CXIndex, modules: List<String>, modulesASTFi
|
||||
}
|
||||
|
||||
internal open class ModularCompilation(compilation: Compilation): Compilation by compilation, Disposable {
|
||||
private val moduleCacheDirectory = createTempDir("ModuleCache")
|
||||
|
||||
override val compilerArgs = compilation.compilerArgs +
|
||||
listOf("-fmodules", "-fmodules-cache-path=${moduleCacheDirectory.absolutePath}")
|
||||
companion object {
|
||||
private const val moduleCacheFlag = "-fmodules-cache-path="
|
||||
}
|
||||
|
||||
private val moduleCacheDirectory = if (compilation.compilerArgs.none { it.startsWith(moduleCacheFlag) }) {
|
||||
createTempDir("ModuleCache")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
override val compilerArgs: List<String> = compilation.compilerArgs +
|
||||
listOfNotNull("-fmodules", moduleCacheDirectory?.let { "$moduleCacheFlag${it.absolutePath}" })
|
||||
|
||||
override fun dispose() {
|
||||
moduleCacheDirectory.deleteRecursively()
|
||||
moduleCacheDirectory?.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ project.rootProject.ext.platformManager.enabled.each { target ->
|
||||
klibs df.config.depends
|
||||
}
|
||||
extraOpts '-Xpurge-user-libs'
|
||||
compilerOpts "-fmodules-cache-path=${project.buildDir}/clangModulesCache"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user