[K/N][build] Build platform libraries without zipping/unzipping

With "-nopack" compiler option, it is possible to build unzipped klibs.
This makes it possible to get rid of install tasks that unzip them.
Also, an obsolete test for klib installation was removed.
This commit is contained in:
Pavel Punegov
2023-10-20 17:56:30 +02:00
committed by Space Team
parent 094490acbd
commit 9961780fbd
6 changed files with 54 additions and 93 deletions
@@ -70,4 +70,6 @@ open class KonanInteropLibrary(name: String,
override fun link(vararg files: Any) = tasks().forEach { it.configure { link(*files) } }
override fun link(files: FileCollection) = tasks().forEach { it.configure { link(files) } }
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { dependencies(closure) }}
override fun noPack(flag: Boolean) = tasks().forEach { it.configure { noPack(flag) } }
}
@@ -103,4 +103,6 @@ interface KonanInteropSpec: KonanBuildingSpec {
fun link(vararg files: Any)
fun link(files: FileCollection)
fun noPack(flag: Boolean)
}
@@ -40,9 +40,17 @@ open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: Wo
}
// Output directories -----------------------------------------------------
override val artifact: File
@Internal get() = destinationDir.resolve(artifactFullName)
val artifactFile: File?
@Optional @OutputFile get() = if (!noPack) artifact else null
val artifactDirectory: File?
@Optional @OutputDirectory get() = if (noPack) artifact else null
override val artifactSuffix: String
@Internal get() = ".klib"
@Internal get() = ".klib".takeUnless { noPack } ?: ""
override val artifactPrefix: String
@Internal get() = ""
@@ -63,6 +71,9 @@ open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: Wo
@InputFiles val headers = mutableSetOf<FileCollection>()
@InputFiles val linkFiles = mutableSetOf<FileCollection>()
@Input
var noPack: Boolean = false
fun buildArgs() = mutableListOf<String>().apply {
addArg("-o", artifact.canonicalPath)
@@ -96,6 +107,8 @@ open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: Wo
addKey("-no-default-libs", noDefaultLibs)
addKey("-no-endorsed-libs", noEndorsedLibs)
addKey("-nopack", noPack)
addAll(extraOpts)
}
@@ -150,10 +163,15 @@ open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: Wo
override fun link(vararg files: Any) {
linkFiles.add(project.files(files))
}
override fun link(files: FileCollection) {
linkFiles.add(files)
}
override fun noPack(flag: Boolean) {
noPack = flag
}
// endregion
internal interface RunToolParameters: WorkParameters {
@@ -1,42 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.plugin.konan.tasks
import org.gradle.api.DefaultTask
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.gradle.plugin.konan.KonanKlibRunner
import org.jetbrains.kotlin.kotlinNativeDist
import java.io.File
open class KonanKlibInstallTask : DefaultTask() {
@get:InputFile
var klib: Provider<File> = project.provider { project.buildDir }
@get:Internal
var repo: File = project.rootDir
val installDir: Provider<File>
@OutputDirectory
get() = project.provider {
val klibName = klib.get().nameWithoutExtension
project.file("${repo.absolutePath}/$klibName")
}
@get:Input
var target: String = HostManager.hostName
@TaskAction
fun exec() {
val args = listOf(
"install", klib.get().absolutePath,
"-target", target,
"-repository", repo.absolutePath
)
KonanKlibRunner(project, konanHome = project.kotlinNativeDist.absolutePath).run(args)
}
}