[K/N][build] Move stdlib caching to runtime project

This commit is contained in:
Pavel Punegov
2021-10-18 15:16:33 +03:00
committed by Space
parent c9d203b01a
commit 67eedbe03e
3 changed files with 21 additions and 19 deletions
+1 -1
View File
@@ -471,7 +471,7 @@ targetList.each { target ->
if (target in cacheableTargetNames) {
task ("${target}StdlibCache", type: Copy) {
dependsOn "${target}CrossDistStdlib"
dependsOn ":kotlin-native:platformLibs:${target}StdlibCache"
dependsOn ":kotlin-native:runtime:${target}StdlibCache"
destinationDir project.file("$distDir/klib/cache/")
+1 -12
View File
@@ -55,17 +55,6 @@ rootProject.project("kotlin-native").ext.platformManager.enabled.each { target -
ArrayList<TaskProvider> installTasks = []
ArrayList<TaskProvider> cacheTasks = []
if (target in cacheableTargets) {
tasks.register("${targetName}StdlibCache", KonanCacheTask) {
it.target = targetName
def runtimeBuild = project(":kotlin-native:runtime").buildDir
it.originalKlib = project.file("$runtimeBuild/${target}Stdlib")
it.cacheRoot = project.file("$runtimeBuild/cache/$target").path
it.dependsOn ":kotlin-native:${targetName}CrossDistRuntime"
}
}
targetDefFiles(target).each { df ->
def libName = defFileToLibName(targetName, df.name)
def fileNamePrefix = PlatformLibsInfo.namePrefix
@@ -107,7 +96,7 @@ rootProject.project("kotlin-native").ext.platformManager.enabled.each { target -
def cacheTask = tasks.register("${libName}Cache", KonanCacheTask) {
it.target = targetName
it.originalKlib = tasks[libName].installDir.get()
it.cacheRoot = file("$konanHome/klib/cache")
it.cacheRoot = file("$konanHome/klib/cache").absolutePath
it.dependsOn ":kotlin-native:${targetName}StdlibCache"
it.dependsOn tasks[libName]
+19 -6
View File
@@ -5,6 +5,7 @@
import org.jetbrains.kotlin.*
import org.jetbrains.kotlin.testing.native.*
import org.jetbrains.kotlin.bitcode.CompileToBitcode
import org.jetbrains.kotlin.gradle.plugin.konan.tasks.KonanCacheTask
import org.jetbrains.kotlin.konan.properties.loadProperties
import org.jetbrains.kotlin.konan.properties.saveProperties
import org.jetbrains.kotlin.konan.target.*
@@ -437,27 +438,39 @@ konanArtifacts {
}
}
targetList.forEach { target ->
tasks.register("${target}Stdlib", Copy::class.java) {
targetList.forEach { targetName ->
tasks.register("${targetName}Stdlib", Copy::class.java) {
require(::stdlibBuildTask.isInitialized)
dependsOn(stdlibBuildTask)
dependsOn("${target}Runtime")
dependsOn("${targetName}Runtime")
destinationDir = project.buildDir.resolve("${target}Stdlib")
destinationDir = project.buildDir.resolve("${targetName}Stdlib")
from(project.buildDir.resolve("stdlib/${hostName}/stdlib"))
if (target != hostName) {
if (targetName != hostName) {
doLast {
// Change target in manifest file
with(KFile(destinationDir.resolve("default/manifest").absolutePath)) {
loadProperties().also {
it[KLIB_PROPERTY_NATIVE_TARGETS] = target
it[KLIB_PROPERTY_NATIVE_TARGETS] = targetName
saveProperties(it)
}
}
}
}
}
val cacheableTargetNames: List<String> by project
if (targetName in cacheableTargetNames) {
tasks.register("${targetName}StdlibCache", KonanCacheTask::class.java) {
target = targetName
originalKlib = project.buildDir.resolve("${targetName}Stdlib")
cacheRoot = project.buildDir.resolve("cache/$targetName").absolutePath
dependsOn(":kotlin-native:${targetName}CrossDistRuntime")
}
}
}
// endregion