[K/N][build] Split stdlib and endorsed libraries build and caching
Due to the usage of dist as an input and output at the same time by different tasks Gradle issued warning about Execution optimizations turning off. The fix is to split inputs and outputs in the build and cache tasks of stdlib and endorsed libs.
This commit is contained in:
+15
-1
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import java.nio.file.Files
|
||||
import org.jetbrains.kotlin.*
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
internal interface KonanToolRunner : Named {
|
||||
val mainClass: String
|
||||
@@ -109,7 +110,10 @@ internal abstract class KonanCliRunner(
|
||||
val launcher = project.getProperty(KonanPlugin.ProjectProperty.KONAN_JVM_LAUNCHER) as? Provider<JavaLauncher>
|
||||
?: throw IllegalStateException("Missing property: ${KonanPlugin.ProjectProperty.KONAN_JVM_LAUNCHER}")
|
||||
|
||||
project.exec(object : Action<ExecSpec> {
|
||||
val out = ByteArrayOutputStream()
|
||||
val err = ByteArrayOutputStream()
|
||||
|
||||
val execResult = project.exec(object : Action<ExecSpec> {
|
||||
override fun execute(exec: ExecSpec) {
|
||||
exec.executable = launcher.get().executablePath.toString()
|
||||
val properties = System.getProperties().asSequence()
|
||||
@@ -131,8 +135,18 @@ internal abstract class KonanCliRunner(
|
||||
})
|
||||
blacklistEnvironment.forEach { environment.remove(it) }
|
||||
exec.environment(environment)
|
||||
exec.errorOutput = err
|
||||
exec.standardOutput = out
|
||||
exec.isIgnoreExitValue = true
|
||||
}
|
||||
})
|
||||
|
||||
check(execResult.exitValue == 0) {
|
||||
"""
|
||||
stdout:$out
|
||||
stderr:$err
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-4
@@ -20,8 +20,8 @@ open class KonanCacheTask: DefaultTask() {
|
||||
lateinit var originalKlib: File
|
||||
|
||||
// Taken into account by the [cacheFile] property.
|
||||
@Internal
|
||||
lateinit var cacheRoot: File
|
||||
@Input
|
||||
lateinit var cacheRoot: String
|
||||
|
||||
@get:Input
|
||||
lateinit var target: String
|
||||
@@ -29,7 +29,10 @@ open class KonanCacheTask: DefaultTask() {
|
||||
@get:Internal
|
||||
// TODO: Reuse NativeCacheKind from Big Kotlin plugin when it is available.
|
||||
val cacheDirectory: File
|
||||
get() = cacheRoot.resolve("$target-g$cacheKind")
|
||||
get() = File(cacheRoot).apply {
|
||||
if (!exists()) mkdir()
|
||||
resolve("$target-g$cacheKind")
|
||||
}
|
||||
|
||||
@get:OutputDirectory
|
||||
protected val cacheFile: File
|
||||
@@ -49,6 +52,10 @@ open class KonanCacheTask: DefaultTask() {
|
||||
set(project.provider { project.kotlinNativeDist })
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
var cachedLibrary: String? = null
|
||||
|
||||
@TaskAction
|
||||
fun compile() {
|
||||
// Compiler doesn't create a cache if the cacheFile already exists. So we need to remove it manually.
|
||||
@@ -66,7 +73,7 @@ open class KonanCacheTask: DefaultTask() {
|
||||
"-produce", cacheKind.outputKind.name.toLowerCase(),
|
||||
"-Xadd-cache=${originalKlib.absolutePath}",
|
||||
"-Xcache-directory=${cacheDirectory.absolutePath}"
|
||||
) + additionalCacheFlags
|
||||
) + additionalCacheFlags + (cachedLibrary?.let { "-Xcached-library=$it" } ?: "")
|
||||
KonanCompilerRunner(project, konanHome = konanHome).run(args)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user