Native: don't pack endorsed libraries (namely kotlinx.cli) into dist
The overall concept of "endorsed" libraries is currently unmaintained and non-reviewed. kotlinx-cli is in its alpha, and is available from Maven. See also KT-54098.
This commit is contained in:
committed by
Space Team
parent
7b45f75213
commit
16acb72521
@@ -210,14 +210,9 @@ task distNativeSources(type: Zip) {
|
||||
}
|
||||
}
|
||||
|
||||
task distEndorsedSources {
|
||||
dependsOn(':kotlin-native:endorsedLibraries:endorsedLibsSources')
|
||||
}
|
||||
|
||||
task distSources {
|
||||
dependsOn(distCommonSources)
|
||||
dependsOn(distNativeSources)
|
||||
dependsOn(distEndorsedSources)
|
||||
}
|
||||
|
||||
task shadowJar(type: ShadowJar) {
|
||||
@@ -346,35 +341,19 @@ task distRuntime(type: Copy) {
|
||||
dependsOn "${hostName}CrossDistRuntime"
|
||||
}
|
||||
|
||||
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'
|
||||
def endorsedLibsBase = 'klib/common'
|
||||
|
||||
task crossDistRuntime {
|
||||
dependsOn.addAll(targetList.collect { "${it}CrossDistRuntime" })
|
||||
}
|
||||
|
||||
task crossDistEndorsedLibraries {
|
||||
dependsOn.addAll(targetList.collect { "${it}CrossDistEndorsedLibraries" })
|
||||
}
|
||||
|
||||
task crossDistPlatformLibs {
|
||||
dependsOn.addAll(targetList.collect { "${it}PlatformLibs" })
|
||||
}
|
||||
@@ -387,19 +366,6 @@ task crossDistStdlibCache {
|
||||
dependsOn.addAll(targetList.findAll { it in cacheableTargetNames }.collect { "${it}StdlibCache" })
|
||||
}
|
||||
|
||||
task crossDistEndorsedCache {
|
||||
dependsOn.addAll(targetList.findAll { it in cacheableTargetNames }.collect { "${it}EndorsedCache" })
|
||||
}
|
||||
|
||||
def endorsedLibsCopyTask = task("crossDistEndorsedLibrariesCopy", type: Copy) {
|
||||
destinationDir project.file("$distDir/$endorsedLibsBase")
|
||||
|
||||
from(project(':kotlin-native:endorsedLibraries').file("build")) {
|
||||
include('**')
|
||||
exclude('cache')
|
||||
}
|
||||
}
|
||||
|
||||
targetList.each { target ->
|
||||
task("${target}CrossDistStdlib", type: Copy) {
|
||||
dependsOn ":kotlin-native:runtime:${target}Stdlib"
|
||||
@@ -419,7 +385,7 @@ targetList.each { target ->
|
||||
include('**')
|
||||
} else {
|
||||
// We don't want to rewrite stdlib parts as they are the same and may be already used
|
||||
// by the other build phases like caching or endorsed libraries.
|
||||
// by the other build phases like caching.
|
||||
include('*/targets/**')
|
||||
include('*/manifest')
|
||||
}
|
||||
@@ -486,36 +452,14 @@ targetList.each { target ->
|
||||
include('**')
|
||||
}
|
||||
}
|
||||
|
||||
task ("${target}EndorsedCache", type: Copy) {
|
||||
dependsOn "${target}CrossDistStdlib"
|
||||
dependsOn ":kotlin-native:endorsedLibraries:${target}Cache"
|
||||
|
||||
destinationDir project.file("$distDir/klib/cache")
|
||||
|
||||
from("${project(':kotlin-native:endorsedLibraries').buildDir}/cache/$target") {
|
||||
include('**')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task("${target}CrossDist") {
|
||||
dependsOn "${target}CrossDistRuntime", "distCompiler"
|
||||
dependsOn "${target}CrossDistEndorsedLibraries"
|
||||
if (target in cacheableTargetNames) {
|
||||
dependsOn "${target}StdlibCache", "${target}EndorsedCache"
|
||||
dependsOn "${target}StdlibCache"
|
||||
}
|
||||
}
|
||||
|
||||
task("${target}CrossDistEndorsedLibraries") {
|
||||
def endorsedLibsBuildTask = ":kotlin-native:endorsedLibraries:${target}EndorsedLibraries"
|
||||
dependsOn endorsedLibsBuildTask
|
||||
dependsOn endorsedLibsCopyTask
|
||||
// There is only one copy task for endorsed libs, because they are already copied into a single dir,
|
||||
// while having target-tasks will make Gradle issue warnings on incorrect inputs and outputs usage.
|
||||
// So this copy task should run after the all build tasks.
|
||||
endorsedLibsCopyTask.mustRunAfter(endorsedLibsBuildTask)
|
||||
}
|
||||
}
|
||||
|
||||
task distPlatformLibs {
|
||||
@@ -526,20 +470,16 @@ task distPlatformLibs {
|
||||
task dist {
|
||||
dependsOn "distCompiler",
|
||||
"distRuntime",
|
||||
"distEndorsedLibraries",
|
||||
"distDef",
|
||||
"distStdlibCache",
|
||||
"distEndorsedCache"
|
||||
"distStdlibCache"
|
||||
}
|
||||
|
||||
task crossDist {
|
||||
dependsOn "distCompiler",
|
||||
"crossDistRuntime",
|
||||
"crossDistEndorsedLibraries",
|
||||
"distDef",
|
||||
"crossDistStdlib",
|
||||
"crossDistStdlibCache",
|
||||
"crossDistEndorsedCache"
|
||||
"crossDistStdlibCache"
|
||||
}
|
||||
|
||||
task bundle {
|
||||
@@ -556,7 +496,7 @@ task bundleRegular(type: (isWindows()) ? Zip : Tar) {
|
||||
exclude 'klib/testLibrary'
|
||||
// Don't include platform libraries into the bundle (generate them at the user side instead).
|
||||
exclude 'klib/platform'
|
||||
// Exclude platform libraries caches too. Keep caches for stdlib and endorsed libs.
|
||||
// Exclude platform libraries caches too. Keep caches for stdlib.
|
||||
exclude 'klib/cache/*/org.jetbrains.kotlin.native.platform.*/**'
|
||||
into "${archiveBaseName.get()}-${archiveVersion.get()}"
|
||||
}
|
||||
@@ -598,7 +538,6 @@ configurePackingLicensesToBundle(bundlePrebuilt, /* containsPlatformLibraries =
|
||||
configure([bundleRegular, bundlePrebuilt]) {
|
||||
dependsOn("crossDist")
|
||||
dependsOn("crossDistStdlibCache")
|
||||
dependsOn("crossDistEndorsedCache")
|
||||
dependsOn("distSources")
|
||||
dependsOn("distDef")
|
||||
from(project.projectDir) {
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
import org.jetbrains.kotlin.EndorsedLibraryInfo
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.kotlinNativeDist
|
||||
import org.jetbrains.kotlin.mergeManifestsByTargets
|
||||
|
||||
if (HostManager.host == KonanTarget.MACOS_ARM64) {
|
||||
project.configureJvmToolchain(JdkMajorVersion.JDK_17_0)
|
||||
}
|
||||
|
||||
plugins {
|
||||
base
|
||||
}
|
||||
|
||||
val endorsedLibraries = listOf(EndorsedLibraryInfo(project("kotlinx.cli"), "org.jetbrains.kotlinx.kotlinx-cli"))
|
||||
|
||||
extra["endorsedLibraries"] = endorsedLibraries.associateBy { it.project }
|
||||
|
||||
tasks.register("jvmJar") {
|
||||
endorsedLibraries.forEach { library ->
|
||||
dependsOn("${library.projectName}:jvmJar")
|
||||
}
|
||||
}
|
||||
|
||||
val targetList: List<String> by project
|
||||
val cacheableTargetNames: List<String> by project
|
||||
|
||||
// Build all default libraries.
|
||||
targetList.forEach { target ->
|
||||
tasks.create("${target}EndorsedLibraries") {
|
||||
endorsedLibraries.forEach { library ->
|
||||
dependsOn(tasks.register("${target}${library.name}EndorsedLibraries", Copy::class.java) {
|
||||
dependsOn("${library.projectName}:${target}${library.taskName}")
|
||||
destinationDir = project.file("${project.buildDir}/${library.name}")
|
||||
|
||||
from(library.project.file("build/${target}${library.name}")) {
|
||||
include("**")
|
||||
eachFile {
|
||||
if (name == "manifest") {
|
||||
val existingManifest = file("$destinationDir/$path")
|
||||
if (existingManifest.exists()) {
|
||||
project.mergeManifestsByTargets(file, existingManifest)
|
||||
exclude()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (target in cacheableTargetNames) {
|
||||
val cacheTask = tasks.register("${target}Cache", Copy::class.java) {
|
||||
destinationDir = project.file("${project.buildDir}/cache/$target")
|
||||
|
||||
endorsedLibraries.forEach { library ->
|
||||
from(library.project.file("build/cache/$target")) {
|
||||
include("**")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endorsedLibraries.forEach { library ->
|
||||
cacheTask.configure {
|
||||
dependsOn("${library.projectName}:${target}${library.taskName}Cache")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endorsedLibraries.forEach { library ->
|
||||
tasks.register("${library.taskName}CommonSources", Zip::class.java) {
|
||||
destinationDirectory.set(file("${project.kotlinNativeDist}/sources"))
|
||||
archiveFileName.set("${library.name}-common-sources.zip")
|
||||
|
||||
includeEmptyDirs = false
|
||||
include("**/*.kt")
|
||||
|
||||
from(library.project.file("src/main/kotlin"))
|
||||
}
|
||||
tasks.register("${library.taskName}NativeSources", Zip::class.java) {
|
||||
destinationDirectory.set(file("${project.kotlinNativeDist}/sources"))
|
||||
archiveFileName.set("${library.name}-native-sources.zip")
|
||||
|
||||
includeEmptyDirs = false
|
||||
include("**/*.kt")
|
||||
|
||||
from(library.project.file("src/main/kotlin-native"))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("endorsedLibsSources") {
|
||||
endorsedLibraries.forEach { library ->
|
||||
dependsOn("${library.taskName}CommonSources")
|
||||
dependsOn("${library.taskName}NativeSources")
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,7 @@
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.tasks.KonanCacheTask
|
||||
import org.jetbrains.kotlin.konan.properties.loadProperties
|
||||
import org.jetbrains.kotlin.konan.properties.saveProperties
|
||||
import org.jetbrains.kotlin.library.KLIB_PROPERTY_NATIVE_TARGETS
|
||||
import org.jetbrains.kotlin.konan.file.File as KFile
|
||||
|
||||
val distDir: File by project
|
||||
val konanHome: String by extra(distDir.absolutePath)
|
||||
extra["org.jetbrains.kotlin.native.home"] = konanHome
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("kotlin.native.build-tools-conventions")
|
||||
id("konan")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -54,88 +43,3 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val commonSrc = project.file("src/main/kotlin")
|
||||
val nativeSrc = project.file("src/main/kotlin-native")
|
||||
|
||||
val targetList: List<String> by project
|
||||
val endorsedLibraries: Map<Project, EndorsedLibraryInfo> by project(":kotlin-native:endorsedLibraries").ext
|
||||
|
||||
val library = endorsedLibraries[project] ?: throw IllegalStateException("Library for $project is not set")
|
||||
|
||||
konanArtifacts {
|
||||
library(library.name) {
|
||||
baseDir(project.buildDir.resolve(library.name))
|
||||
|
||||
noPack(true)
|
||||
noDefaultLibs(true)
|
||||
noEndorsedLibs(true)
|
||||
enableMultiplatform(true)
|
||||
|
||||
// See :endorsedLibraries.ext for full endorsedLibraries list.
|
||||
val moduleName = endorsedLibraries[project]?.name.toString()
|
||||
|
||||
extraOpts(project.globalBuildArgs)
|
||||
extraOpts(
|
||||
"-Werror",
|
||||
"-module-name", moduleName,
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalMultiplatform",
|
||||
"-opt-in=kotlinx.cli.ExperimentalCli"
|
||||
)
|
||||
|
||||
commonSrcDir(commonSrc)
|
||||
srcDir(nativeSrc)
|
||||
|
||||
dependsOn(":kotlin-native:distCompiler")
|
||||
dependsOn(":kotlin-native:distRuntime")
|
||||
}
|
||||
}
|
||||
|
||||
val hostName: String by project
|
||||
val cacheableTargetNames: List<String> by project
|
||||
|
||||
targetList.forEach { targetName ->
|
||||
val copyTask = tasks.register("${targetName}${library.taskName}", Copy::class.java) {
|
||||
dependsOn(project.findKonanBuildTask(library.name, project.platformManager.hostPlatform.target))
|
||||
|
||||
destinationDir = buildDir.resolve("$targetName${library.name}")
|
||||
|
||||
// We build a single klib file for host platform and then copy it to other platforms
|
||||
// creating target dirs and adding targets to manifest file
|
||||
val libFile = buildDir.resolve("${library.name}/${hostName}/${library.name}")
|
||||
from(libFile) {
|
||||
exclude("default/targets/$hostName")
|
||||
}
|
||||
from(libFile.resolve("default/targets/$hostName")) {
|
||||
into("default/targets/$targetName")
|
||||
}
|
||||
|
||||
if (targetName != hostName) {
|
||||
doLast {
|
||||
// Change target in manifest file
|
||||
with(KFile(destinationDir.resolve("default/manifest").absolutePath)) {
|
||||
val props = loadProperties()
|
||||
props[KLIB_PROPERTY_NATIVE_TARGETS] = targetName
|
||||
saveProperties(props)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetName in cacheableTargetNames) {
|
||||
tasks.register("${targetName}${library.taskName}Cache", KonanCacheTask::class.java) {
|
||||
target = targetName
|
||||
originalKlib = project.buildDir.resolve("$targetName${library.name}")
|
||||
klibUniqName = library.name
|
||||
cacheRoot = project.buildDir.resolve("cache/$targetName").absolutePath
|
||||
|
||||
cachedLibraries = mapOf(distDir.resolve("klib/common/stdlib") to
|
||||
distDir.resolve("klib/cache/${target}-g$cacheKind/stdlib-cache"))
|
||||
|
||||
dependsOn(copyTask)
|
||||
dependsOn(":kotlin-native:${targetName}CrossDistStdlib")
|
||||
dependsOn(":kotlin-native:${targetName}StdlibCache")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -811,7 +811,6 @@ if (buildProperties.isKotlinNativeEnabled) {
|
||||
}
|
||||
include ':kotlin-native:dependencies'
|
||||
include ':kotlin-native:endorsedLibraries:kotlinx.cli'
|
||||
include ':kotlin-native:endorsedLibraries'
|
||||
include ':kotlin-native:Interop:StubGenerator'
|
||||
include ':kotlin-native:backend.native'
|
||||
include ':kotlin-native:Interop:Runtime'
|
||||
|
||||
Reference in New Issue
Block a user