diff --git a/kotlin-native/build.gradle b/kotlin-native/build.gradle index 72265158496..175a72aad81 100644 --- a/kotlin-native/build.gradle +++ b/kotlin-native/build.gradle @@ -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/") diff --git a/kotlin-native/platformLibs/build.gradle b/kotlin-native/platformLibs/build.gradle index 2b86dd15345..5bbefed7509 100644 --- a/kotlin-native/platformLibs/build.gradle +++ b/kotlin-native/platformLibs/build.gradle @@ -55,17 +55,6 @@ rootProject.project("kotlin-native").ext.platformManager.enabled.each { target - ArrayList installTasks = [] ArrayList 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] diff --git a/kotlin-native/runtime/build.gradle.kts b/kotlin-native/runtime/build.gradle.kts index dcd8ee08fab..042da5ac98b 100644 --- a/kotlin-native/runtime/build.gradle.kts +++ b/kotlin-native/runtime/build.gradle.kts @@ -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 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 \ No newline at end of file