[K/N][build] Fix up-do-date checks for cache tasks
A name of a cache directory produced by the compiler for a library is based on the unique name of this library. The cache task, when declaring its outputs, assumes that this unique name is equal to the name of the library file/directory. If this is not the case, the up-to-date check works inconsistently and Gradle doesn't rerun the task. This patch fixes this issue by obtaining the real unique name of the library.
This commit is contained in:
+10
-3
@@ -6,8 +6,11 @@ import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanCompilerRunner
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.konanHome
|
||||
import org.jetbrains.kotlin.konan.library.defaultResolver
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.Distribution
|
||||
import org.jetbrains.kotlin.konan.target.PlatformManager
|
||||
import org.jetbrains.kotlin.library.uniqueName
|
||||
import org.jetbrains.kotlin.*
|
||||
import java.io.File
|
||||
|
||||
@@ -34,9 +37,13 @@ open class KonanCacheTask: DefaultTask() {
|
||||
@get:OutputDirectory
|
||||
val cacheFile: File
|
||||
get() {
|
||||
val klibName = originalKlib?.let {
|
||||
if (it.isDirectory) it.name else it.nameWithoutExtension
|
||||
}
|
||||
val konanHome = compilerDistributionPath.get().absolutePath
|
||||
val resolver = defaultResolver(
|
||||
emptyList(),
|
||||
PlatformManager(konanHome).targetByName(target),
|
||||
Distribution(konanHome)
|
||||
)
|
||||
val klibName = resolver.resolve(originalKlib!!.absolutePath).uniqueName
|
||||
return cacheDirectory.resolve("${klibName}-cache")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user