Add prebuilt distribution type

Since platform libraries can now be generated at the use side,
we need to:

a) remove them from a default distribution
b) drop the restricted distribution

But we still need a distribution with prebuilt libraries to be
able to workaround problems with platform libraries generator.

This patch removes libraries from a default distribution and
adds a distribution type with pretuilt libraries.
This commit is contained in:
Ilya Matveev
2020-01-28 17:28:16 +07:00
committed by Ilya Matveev
parent 3af8564bf6
commit 764be2f461
5 changed files with 137 additions and 67 deletions
+76 -50
View File
@@ -405,6 +405,18 @@ task distEndorsedLibraries {
dependsOn "${hostName}CrossDistEndorsedLibraries"
}
task distStdlibCache {
if (hostName in cacheableTargetNames) {
dependsOn("${hostName}StdlibCache")
}
}
task distEndorsedCache {
if (hostName in cacheableTargetNames) {
dependsOn("${hostName}EndorsedCache")
}
}
def stdlib = 'klib/common/stdlib'
def stdlibDefaultComponent = "$stdlib/default"
def endorsedLibs = 'klib/common/endorsedLibraries'
@@ -433,6 +445,14 @@ task crossDistPlatformLibs {
dependsOn.addAll(targetList.collect { "${it}PlatformLibs" })
}
task crossDistStdlibCache {
dependsOn.addAll(targetList.findAll { it in cacheableTargetNames }.collect { "${it}StdlibCache" })
}
task crossDistEndorsedCache {
dependsOn.addAll(targetList.findAll { it in cacheableTargetNames }.collect { "${it}EndorsedCache" })
}
targetList.each { target ->
task("${target}CrossDistRuntime", type: Copy) {
dependsOn ":runtime:${target}Runtime"
@@ -469,6 +489,16 @@ targetList.each { target ->
}
}
if (target in cacheableTargetNames) {
task "${target}StdlibCache" {
dependsOn ":platformLibs:${target}StdlibCache"
}
task "${target}EndorsedCache" {
dependsOn ":endorsedLibraries:${target}Cache"
}
}
task("${target}CrossDist") {
dependsOn "${target}CrossDistRuntime", 'distCompiler', 'commonDistRuntime', "${target}CrossDistEndorsedLibraries"
}
@@ -497,66 +527,55 @@ task crossDist {
dependsOn 'crossDistRuntime', 'distCompiler', 'crossDistEndorsedLibraries'
}
task bundle(type: (isWindows()) ? Zip : Tar) {
dependsOn("distDef")
if (isMac()) {
dependsOn('bundleRestricted')
}
def simpleOsName = HostManager.simpleOsName()
baseName = "kotlin-native-$simpleOsName-$konanVersionFull"
from("$project.rootDir/dist") {
include '**'
exclude 'dependencies'
exclude 'klib/testLibrary'
into baseName
}
from(project.rootDir) {
include 'licenses/**'
into baseName
}
if (isWindows()) {
zip64 true
} else {
extension = 'tar.gz'
compression = Compression.GZIP
}
task bundle {
dependsOn 'bundleRegular', 'bundlePrebuilt'
}
task bundleRestricted(type: Tar) {
dependsOn("distDef")
task bundleRegular(type: (isWindows()) ? Zip : Tar) {
def simpleOsName = HostManager.simpleOsName()
baseName = "kotlin-native-restricted-$simpleOsName-$konanVersionFull"
archiveBaseName.set("kotlin-native-$simpleOsName-$konanVersionFull")
from("$project.rootDir/dist") {
include '**'
exclude 'dependencies'
exclude 'klib/testLibrary'
platformManager.targetValues.each { target ->
if (PlatformInfo.isAppleTarget(target)) {
exclude "klib/platform/${target.name}"
exclude {
// Exclude platform libraries caches too.
!it.isDirectory() && it.relativePath.startsWithAny("klib/cache/${target.name}-g") &&
it.name != "libstdlib-cache.a"
}
}
// Don't include platform libraries into the bundle (generate them at the user side instead).
exclude 'klib/platform'
exclude {
// Exclude platform libraries caches too.
!it.isDirectory() && it.relativePath.startsWithAny("klib/cache") &&
it.name != "libstdlib-cache.a" && it.name != "libkotlinx-cli-cache.a"
}
exclude '**/xcode_license.pdf'
into baseName
into archiveBaseName
}
from(project.rootDir) {
include 'licenses/**'
exclude '**/xcode_license.pdf'
into baseName
into archiveBaseName
}
extension = 'tar.gz'
compression = Compression.GZIP
}
configure([bundle, bundleRestricted]) {
dependsOn('crossDistPlatformLibs')
dependsOn('crossDist')
dependsOn('distSources')
task bundlePrebuilt(type: (isWindows()) ? Zip : Tar) {
dependsOn("crossDistPlatformLibs")
def simpleOsName = HostManager.simpleOsName()
archiveBaseName.set("kotlin-native-prebuilt-$simpleOsName-$konanVersionFull")
from("$project.rootDir/dist") {
include '**'
exclude 'dependencies'
exclude 'klib/testLibrary'
into archiveBaseName
}
from(project.rootDir) {
include 'licenses/**'
into archiveBaseName
}
}
configure([bundleRegular, bundlePrebuilt]) {
dependsOn("crossDist")
dependsOn("crossDistStdlibCache")
dependsOn("crossDistEndorsedCache")
dependsOn("distSources")
dependsOn("distDef")
from(project.rootDir) {
include 'DISTRO_README.md'
rename {
@@ -569,7 +588,14 @@ configure([bundle, bundleRestricted]) {
into baseName
}
destinationDir = file('.')
destinationDirectory.set(file('.'))
if (isWindows()) {
zip64 true
} else {
archiveExtension.set('tar.gz')
compression = Compression.GZIP
}
}
task 'tc-dist'(type: (isWindows()) ? Zip : Tar) {
@@ -577,19 +603,19 @@ task 'tc-dist'(type: (isWindows()) ? Zip : Tar) {
dependsOn('dist')
dependsOn('distSources')
def simpleOsName = HostManager.simpleOsName()
baseName = "kotlin-native-dist-$simpleOsName-$konanVersionFull"
archiveBaseName.set("kotlin-native-dist-$simpleOsName-$konanVersionFull")
from("$project.rootDir/dist") {
include '**'
exclude 'dependencies'
into baseName
into archiveBaseName
}
destinationDir = file('.')
destinationDirectory.set(file('.'))
if (isWindows()) {
zip64 true
} else {
extension = 'tar.gz'
archiveExtension.set('tar.gz')
compression = Compression.GZIP
}
}
+33
View File
@@ -1,3 +1,15 @@
import org.jetbrains.kotlin.gradle.plugin.konan.tasks.KonanCacheTask
buildscript {
repositories {
maven { url 'https://cache-redirector.jetbrains.com/jcenter' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$gradlePluginVersion"
}
}
def endorsedLibrariesList = ['kotlinx.cli']
def toTaskName(library) {
@@ -32,6 +44,27 @@ targetList.each { target ->
}
}
}
if (target in cacheableTargetNames) {
def cacheTask = task("${target}Cache")
endorsedLibrariesList.each { library ->
def libraryName = library.replaceAll("\\.", "-")
def dist = rootProject.file("dist")
task("${target}${toTaskName(library)}Cache", type: KonanCacheTask) {
it.target = target
originalKlib = file("${project.buildDir}/$libraryName")
cacheRoot = file("$dist/klib/cache")
compilerDistributionPath.set(distDir)
dependsOn "${target}EndorsedLibraries"
dependsOn ":${target}CrossDist"
dependsOn ":${target}StdlibCache"
cacheTask.dependsOn it
}
}
}
}
endorsedLibrariesList.each { library ->
+1 -5
View File
@@ -108,7 +108,7 @@ project.rootProject.ext.platformManager.enabled.each { target ->
originalKlib = tasks[libName].installDir
cacheRoot = file("$konanHome/klib/cache")
dependsOn "${targetName}StdlibCache"
dependsOn ":${targetName}StdlibCache"
dependsOn tasks[libName]
dependsOn df.config.depends.collect {
def depName = defFileToLibName(targetName, it)
@@ -157,7 +157,3 @@ task cache {
group = BasePlugin.BUILD_GROUP
description = "Builds all the compilation caches"
}
@@ -39,7 +39,8 @@ internal abstract class KonanCliRunner(
val toolName: String,
val fullName: String,
val project: Project,
private val additionalJvmArgs: List<String>
private val additionalJvmArgs: List<String>,
private val konanHome: String
): KonanToolRunner {
override val mainClass = "org.jetbrains.kotlin.cli.utilities.MainKt"
@@ -56,7 +57,7 @@ internal abstract class KonanCliRunner(
setOf("java.endorsed.dirs")
override val classpath: FileCollection =
project.fileTree("${project.konanHome}/konan/lib/")
project.fileTree("$konanHome/konan/lib/")
.apply { include("*.jar") }
override val jvmArgs = HostManager.defaultJvmArgs.toMutableList().apply {
@@ -69,8 +70,8 @@ internal abstract class KonanCliRunner(
}
override val additionalSystemProperties = mutableMapOf(
"konan.home" to project.konanHome,
"java.library.path" to "${project.konanHome}/konan/nativelib"
"konan.home" to konanHome,
"java.library.path" to "$konanHome/konan/nativelib"
)
override val environment = mutableMapOf("LIBCLANG_DISABLE_CRASH_RECOVERY" to "1")
@@ -113,9 +114,11 @@ internal abstract class KonanCliRunner(
}
}
internal class KonanInteropRunner(project: Project, additionalJvmArgs: List<String> = emptyList())
: KonanCliRunner("cinterop", "Kotlin/Native cinterop tool", project, additionalJvmArgs)
{
internal class KonanInteropRunner(
project: Project,
additionalJvmArgs: List<String> = emptyList(),
konanHome: String = project.konanHome
) : KonanCliRunner("cinterop", "Kotlin/Native cinterop tool", project, additionalJvmArgs, konanHome) {
init {
if (HostManager.host == KonanTarget.MINGW_X64) {
//TODO: Oh-ho-ho fix it in more convinient way.
@@ -129,8 +132,9 @@ internal class KonanInteropRunner(project: Project, additionalJvmArgs: List<Stri
internal class KonanCompilerRunner(
project: Project,
additionalJvmArgs: List<String> = emptyList(),
val useArgFile: Boolean = true
) : KonanCliRunner("konanc", "Kotlin/Native compiler", project, additionalJvmArgs)
val useArgFile: Boolean = true,
konanHome: String = project.konanHome
) : KonanCliRunner("konanc", "Kotlin/Native compiler", project, additionalJvmArgs, konanHome)
{
override fun transformArgs(args: List<String>): List<String> {
if (!useArgFile) {
@@ -150,5 +154,8 @@ internal class KonanCompilerRunner(
}
}
internal class KonanKlibRunner(project: Project, additionalJvmArgs: List<String> = emptyList())
: KonanCliRunner("klib", "Klib management tool", project, additionalJvmArgs)
internal class KonanKlibRunner(
project: Project,
additionalJvmArgs: List<String> = emptyList(),
konanHome: String = project.konanHome
) : KonanCliRunner("klib", "Klib management tool", project, additionalJvmArgs, konanHome)
@@ -1,8 +1,10 @@
package org.jetbrains.kotlin.gradle.plugin.konan.tasks
import org.gradle.api.DefaultTask
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.target.CompilerOutputKind
import org.jetbrains.kotlin.konan.target.HostManager
import java.io.File
@@ -42,6 +44,12 @@ open class KonanCacheTask: DefaultTask() {
@Input
var cacheKind: KonanCacheKind = KonanCacheKind.STATIC
@Input
/** Path to a compiler distribution that is used to build this cache. */
val compilerDistributionPath: Property<File> = project.objects.property(File::class.java).apply {
set(project.provider { project.file(project.konanHome) })
}
@TaskAction
fun compile() {
val args = listOf(
@@ -51,6 +59,6 @@ open class KonanCacheTask: DefaultTask() {
"-Xadd-cache=${originalKlib.absolutePath}",
"-Xcache-directory=${cacheDirectory.absolutePath}"
)
KonanCompilerRunner(project).run(args)
KonanCompilerRunner(project, konanHome = compilerDistributionPath.get().absolutePath).run(args)
}
}