[build][native] don't ever fix dist, take it with API
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import org.jetbrains.kotlin.CopyCommonSources
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
|
||||
import org.jetbrains.kotlin.*
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
@@ -239,9 +239,10 @@ targetList.each { target ->
|
||||
task("${target}Stdlib", type: JavaExec) {
|
||||
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
|
||||
// This task depends on distCompiler, so the compiler jar is already in the dist directory.
|
||||
classpath = fileTree("${rootProject.projectDir}/dist/konan/lib") {
|
||||
classpath = fileTree("${UtilsKt.getKotlinNativeDist(project)}/konan/lib") {
|
||||
include "*.jar"
|
||||
}
|
||||
systemProperties "konan.home": UtilsKt.getKotlinNativeDist(project)
|
||||
jvmArgs = konanJvmArgs
|
||||
def testAnnotationCommon = project(":kotlin-test:kotlin-test-annotations-common").files("src/main/kotlin").files
|
||||
def testCommon = project(":kotlin-test:kotlin-test-common").files("src/main/kotlin").files
|
||||
|
||||
@@ -4398,7 +4398,7 @@ standaloneTest("jsinterop_math") {
|
||||
"$jsinterop -pkg kotlinx.interop.wasm.math -o $buildDir/jsmath -target wasm32".execute().waitFor()
|
||||
|
||||
}
|
||||
dependsOn ':wasm32PlatformLibs'
|
||||
dependsOn ':kotlin-native:wasm32PlatformLibs'
|
||||
enabled = (project.testTarget == 'wasm32')
|
||||
goldValue = "e = 2.718281828459045, pi = 3.141592653589793, sin(pi) = 1.2246467991473532E-16, sin(pi/2) = 1.0, ln(1) = 0.0, ln(e) = 1.0\n"
|
||||
source = "jsinterop/math.kt"
|
||||
@@ -4707,9 +4707,8 @@ if (isAppleTarget(project)) {
|
||||
library(libraryName, targets: [target.name]) {
|
||||
srcDir "objcexport/library"
|
||||
artifactName "test-library"
|
||||
|
||||
if (!useCustomDist) {
|
||||
dependsOn ":kotlin-native:${target.name}CrossDistRuntime", ':kotlin-native:distCompiler'
|
||||
delegate.getByTarget(target.name).configure{
|
||||
UtilsKt.dependsOnDist(it)
|
||||
}
|
||||
|
||||
extraOpts "-Xshort-module-name=MyLibrary"
|
||||
@@ -4735,8 +4734,8 @@ if (isAppleTarget(project)) {
|
||||
srcDir "objcexport/library"
|
||||
artifactName "test-library"
|
||||
|
||||
if (!useCustomDist) {
|
||||
dependsOn ":kotlin-native:${target.name}CrossDistRuntime", ':kotlin-native:distCompiler'
|
||||
delegate.getByTarget(target.name).configure{
|
||||
UtilsKt.dependsOnDist(it)
|
||||
}
|
||||
|
||||
extraOpts "-Xshort-module-name=MyLibrary"
|
||||
@@ -5051,7 +5050,7 @@ private void configureStdlibTest(KonanGTest task, boolean inWorker) {
|
||||
extraOpts inWorker ? '-trw' : '-tr',
|
||||
'-Xverify-ir',
|
||||
'-Xopt-in=kotlin.RequiresOptIn,kotlin.ExperimentalStdlibApi',
|
||||
"-friend-modules", project.rootProject.file("${project.properties['konan.home']}/klib/common/stdlib").absolutePath
|
||||
"-friend-modules", project.rootProject.file("${UtilsKt.getKotlinNativeDist(project)}/klib/common/stdlib").absolutePath
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.gradle.api.tasks.JavaExec
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.process.ExecResult
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
import org.jetbrains.kotlin.*
|
||||
|
||||
import java.nio.file.Paths
|
||||
import java.util.function.Function
|
||||
@@ -83,6 +84,7 @@ class RunExternalTestGroup extends JavaExec implements CompilerRunner {
|
||||
include '*.jar'
|
||||
}
|
||||
jvmArgs "-Xmx4G"
|
||||
jvmArgs "-Dkonan.home=${UtilsKt.getKotlinNativeDist(project)}"
|
||||
enableAssertions = true
|
||||
def sources = File.createTempFile(name,".lst")
|
||||
sources.deleteOnExit()
|
||||
|
||||
@@ -35,15 +35,7 @@ fun configureCacheTesting(project: Project): CacheTesting? {
|
||||
cacheDir.mkdirs()
|
||||
}
|
||||
|
||||
if (!(project.property("useCustomDist") as Boolean)) {
|
||||
val tasks = listOf(
|
||||
"${target}CrossDist",
|
||||
"${target}CrossDistRuntime",
|
||||
"distCompiler"
|
||||
).map { task -> project.rootProject.tasks.getByName(task) }
|
||||
|
||||
dependsOn(tasks)
|
||||
}
|
||||
dependsOnDist()
|
||||
|
||||
commandLine(
|
||||
"$dist/bin/konanc",
|
||||
|
||||
@@ -50,10 +50,15 @@ val Project.testOutputFramework
|
||||
val Project.testOutputExternal
|
||||
get() = (findProperty("testOutputExternal") as File).toString()
|
||||
|
||||
val validPropertiesNames = listOf("kotlin.native.home",
|
||||
"org.jetbrains.kotlin.native.home",
|
||||
"konan.home")
|
||||
|
||||
val Project.kotlinNativeDist
|
||||
get() = this.rootProject.file(findProperty("kotlin.native.home")
|
||||
?: findProperty("org.jetbrains.kotlin.native.home")
|
||||
?: findProperty("konan.home") ?: "dist")
|
||||
get() = rootProject.file(validPropertiesNames.firstOrNull{ hasProperty(it) }?.let{ findProperty(it) } ?: "dist")
|
||||
|
||||
val kotlinNativeHome
|
||||
get() = validPropertiesNames.mapNotNull(System::getProperty).first()
|
||||
|
||||
val Project.useCustomDist
|
||||
get() = hasProperty("kotlin.native.home") ||
|
||||
@@ -132,15 +137,12 @@ fun Project.dependsOnDist(taskName: String) {
|
||||
}
|
||||
|
||||
fun Task.dependsOnDist() {
|
||||
// We don't build the compiler if a custom dist path is specified.
|
||||
if (!(project.findProperty("useCustomDist") as Boolean)) {
|
||||
dependsOn(":kotlin-native:dist")
|
||||
val target = project.testTarget
|
||||
if (target != HostManager.host) {
|
||||
// if a test_target property is set then tests should depend on a crossDist
|
||||
// otherwise, runtime components would not be build for a target.
|
||||
dependsOn(":kotlin-native:${target.name}CrossDist")
|
||||
}
|
||||
dependsOn(":kotlin-native:dist")
|
||||
val target = project.testTarget
|
||||
if (target != HostManager.host) {
|
||||
// if a test_target property is set then tests should depend on a crossDist
|
||||
// otherwise, runtime components would not be build for a target.
|
||||
dependsOn(":kotlin-native:${target.name}CrossDist")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ if (isMac()) {
|
||||
}
|
||||
|
||||
ext {
|
||||
distDir = rootProject.file('dist')
|
||||
distDir = UtilsKt.getKotlinNativeDist(project)
|
||||
dependenciesDir = DependencyProcessor.defaultDependenciesRoot
|
||||
experimentalEnabled = project.hasProperty("org.jetbrains.kotlin.native.experimentalTargets")
|
||||
platformManager = new PlatformManager(DistributionKt.buildDistribution(projectDir.absolutePath),
|
||||
|
||||
@@ -66,6 +66,7 @@ java_opts=(-ea \
|
||||
-Xmx3G \
|
||||
-XX:TieredStopAtLevel=1 \
|
||||
-Dfile.encoding=UTF-8 \
|
||||
-Dkonan.home=$KONAN_HOME \
|
||||
${JAVA_OPTS})
|
||||
|
||||
# Unset some environment variables which are set by XCode and may potentially affect the tool executed.
|
||||
|
||||
@@ -57,11 +57,11 @@ set "KONAN_JAR=%KONAN_LIB%\kotlin-native.jar"
|
||||
set TROVE_JAR="%KONAN_LIB%\trove4j.jar"
|
||||
|
||||
set "KONAN_CLASSPATH=%KONAN_JAR%;%TROVE_JAR%"
|
||||
|
||||
set JAVA_OPTS=-ea ^
|
||||
-Xmx3G ^
|
||||
-XX:TieredStopAtLevel=1 ^
|
||||
-Dfile.encoding=UTF-8 ^
|
||||
-Dkonan.home=%_KONAN_HOME% ^
|
||||
%JAVA_OPTS%
|
||||
|
||||
set LIBCLANG_DISABLE_CRASH_RECOVERY=1
|
||||
|
||||
@@ -59,7 +59,7 @@ targetList.each { target ->
|
||||
def cacheTask = task("${target}Cache")
|
||||
|
||||
endorsedLibrariesList.each { library ->
|
||||
def dist = rootProject.file("dist")
|
||||
def dist = UtilsKt.getKotlinNativeDist(project)
|
||||
task("${target}${library.taskName}Cache", type: KonanCacheTask) {
|
||||
it.target = target
|
||||
originalKlib = file("${project.buildDir}/${library.name}")
|
||||
@@ -78,7 +78,7 @@ targetList.each { target ->
|
||||
|
||||
endorsedLibrariesList.each { library ->
|
||||
task("${library.taskName}CommonSources", type: Zip) {
|
||||
destinationDirectory = file("${rootProject.projectDir}/dist/sources")
|
||||
destinationDirectory = file("${UtilsKt.getKotlinNativeDist(project)}/dist/sources")
|
||||
archiveFileName = "${library.name}-common-sources.zip"
|
||||
|
||||
includeEmptyDirs = false
|
||||
@@ -87,7 +87,7 @@ endorsedLibrariesList.each { library ->
|
||||
from(library.project.file('src/main/kotlin'))
|
||||
}
|
||||
task("${library.taskName}NativeSources", type: Zip) {
|
||||
destinationDirectory = file("${rootProject.projectDir}/dist/sources")
|
||||
destinationDirectory = file("${UtilsKt.getKotlinNativeDist(project)}/dist/sources")
|
||||
archiveFileName = "${library.name}-native-sources.zip"
|
||||
|
||||
includeEmptyDirs = false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.util.PlatformLibsInfo
|
||||
import org.jetbrains.kotlin.*
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -82,9 +83,11 @@ targetList.each { target ->
|
||||
dependsOn ":kotlin-native:distCompiler"
|
||||
dependsOn ":kotlin-native:${target}CrossDistRuntime"
|
||||
|
||||
def kotlinNativeDist = UtilsKt.getKotlinNativeDist(project)
|
||||
systemProperties "konan.home": kotlinNativeDist
|
||||
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
|
||||
// This task depends on distCompiler, so the compiler jar is already in the dist directory.
|
||||
classpath = fileTree("${rootProject.projectDir}/dist/konan/lib") {
|
||||
classpath = fileTree("$kotlinNativeDist/konan/lib") {
|
||||
include "*.jar"
|
||||
}
|
||||
jvmArgs = konanJvmArgs
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
org.jetbrains.kotlin.native.home=../../dist
|
||||
org.jetbrains.kotlin.native.jvmArgs=-Xmx6G
|
||||
+3
-3
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.buildDistribution
|
||||
import org.jetbrains.kotlin.konan.target.customerDistribution
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import org.jetbrains.kotlin.*
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -87,8 +88,7 @@ internal fun Project.setProperty(property: KonanPlugin.ProjectProperty, value: A
|
||||
// konanHome extension is set by downloadKonanCompiler task.
|
||||
internal val Project.konanHome: String
|
||||
get() {
|
||||
assert(hasProperty(KonanPlugin.ProjectProperty.KONAN_HOME))
|
||||
return project.file(getProperty(KonanPlugin.ProjectProperty.KONAN_HOME)).canonicalPath
|
||||
return project.kotlinNativeDist.absolutePath
|
||||
}
|
||||
|
||||
internal val Project.konanVersion: CompilerVersion
|
||||
@@ -346,7 +346,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
project.warnAboutDeprecatedProperty(ProjectProperty.KONAN_HOME)
|
||||
|
||||
// Set additional project properties like org.jetbrains.kotlin.native.home, konan.build.targets etc.
|
||||
if (!project.hasProperty(ProjectProperty.KONAN_HOME)) {
|
||||
if (!project.useCustomDist) {
|
||||
project.setProperty(ProjectProperty.KONAN_HOME, project.konanCompilerDownloadDir())
|
||||
project.setProperty(ProjectProperty.DOWNLOAD_COMPILER, true)
|
||||
}
|
||||
|
||||
+2
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import java.nio.file.Files
|
||||
import org.jetbrains.kotlin.*
|
||||
|
||||
internal interface KonanToolRunner: Named {
|
||||
val mainClass: String
|
||||
@@ -105,6 +106,7 @@ internal abstract class KonanCliRunner(
|
||||
.escapeQuotesForWindows()
|
||||
.toMap()
|
||||
)
|
||||
exec.systemProperty("konan.home", project.kotlinNativeDist.absolutePath)
|
||||
exec.args(listOf(toolName) + transformArgs(args))
|
||||
this@KonanCliRunner.blacklistEnvironment.forEach { environment.remove(it) }
|
||||
exec.environment(environment)
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ 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.PlatformManager
|
||||
import org.jetbrains.kotlin.*
|
||||
import java.io.File
|
||||
|
||||
enum class KonanCacheKind(val outputKind: CompilerOutputKind) {
|
||||
@@ -45,7 +46,7 @@ open class KonanCacheTask: DefaultTask() {
|
||||
@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) })
|
||||
set(project.provider { project.kotlinNativeDist })
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.konan.MetaVersion
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import org.jetbrains.kotlin.konan.util.DependencySource
|
||||
import java.io.IOException
|
||||
import org.jetbrains.kotlin.*
|
||||
|
||||
open class KonanCompilerDownloadTask : DefaultTask() {
|
||||
|
||||
@@ -40,7 +41,7 @@ open class KonanCompilerDownloadTask : DefaultTask() {
|
||||
@TaskAction
|
||||
fun downloadAndExtract() {
|
||||
if (!project.hasProperty(KonanPlugin.ProjectProperty.DOWNLOAD_COMPILER)) {
|
||||
val konanHome = project.getProperty(KonanPlugin.ProjectProperty.KONAN_HOME)
|
||||
val konanHome = project.kotlinNativeDist
|
||||
logger.info("Use a user-defined compiler path: $konanHome")
|
||||
} else {
|
||||
try {
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package org.jetbrains.kotlin.konan.util
|
||||
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.kotlin.*
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
|
||||
object KonanHomeProvider {
|
||||
|
||||
internal val validPropertiesNames = listOf("kotlin.native.home",
|
||||
"org.jetbrains.kotlin.native.home",
|
||||
"konan.home")
|
||||
internal val kotlinNativeHome
|
||||
get() = validPropertiesNames.mapNotNull(System::getProperty).first()
|
||||
/**
|
||||
* Determines a path to the current Kotlin/Native distribution.
|
||||
*
|
||||
@@ -15,7 +20,7 @@ object KonanHomeProvider {
|
||||
* Otherwise an IllegalStateException is thrown.
|
||||
*/
|
||||
fun determineKonanHome(): String {
|
||||
val propertyValue = System.getProperty("konan.home")
|
||||
val propertyValue = kotlinNativeHome
|
||||
return if (propertyValue != null) {
|
||||
File(propertyValue).absolutePath
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user