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