[build][tests] more utilities functions used
This commit is contained in:
@@ -22,17 +22,12 @@ buildscript {
|
|||||||
url project.bootstrapKotlinRepo
|
url project.bootstrapKotlinRepo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ext.useCustomDist = project.hasProperty("kotlin.native.home") ||
|
ext.useCustomDist = UtilsKt.getUseCustomDist(project)
|
||||||
project.hasProperty("org.jetbrains.kotlin.native.home") ||
|
ext.kotlinNativeDist = UtilsKt.getKotlinNativeDist(project)
|
||||||
project.hasProperty("konan.home")
|
|
||||||
ext.kotlinNativeDist = project.findProperty("kotlin.native.home")
|
|
||||||
?: project.findProperty("org.jetbrains.kotlin.native.home")
|
|
||||||
?: project.findProperty("konan.home")
|
|
||||||
?: distDir.absolutePath
|
|
||||||
if (!useCustomDist) {
|
if (!useCustomDist) {
|
||||||
ext.setProperty("kotlin.native.home", distDir.absolutePath)
|
ext.setProperty("kotlin.native.home", kotlinNativeDist.absolutePath)
|
||||||
ext.setProperty("org.jetbrains.kotlin.native.home", distDir.absolutePath)
|
ext.setProperty("org.jetbrains.kotlin.native.home", kotlinNativeDist.absolutePath)
|
||||||
ext.setProperty("konan.home", distDir.absolutePath)
|
ext.setProperty("konan.home", kotlinNativeDist.absolutePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,9 +128,6 @@ allprojects {
|
|||||||
testOutputExternal.mkdirs()
|
testOutputExternal.mkdirs()
|
||||||
testOutputStdlib.mkdirs()
|
testOutputStdlib.mkdirs()
|
||||||
|
|
||||||
ext.dist = project.rootProject.file(project.findProperty("org.jetbrains.kotlin.native.home") ?:
|
|
||||||
project.findProperty("konan.home") ?: "dist")
|
|
||||||
|
|
||||||
konanArtifacts {
|
konanArtifacts {
|
||||||
library('testLibrary') {
|
library('testLibrary') {
|
||||||
if (!useCustomDist) {
|
if (!useCustomDist) {
|
||||||
@@ -166,7 +158,7 @@ def installTestLib = tasks.register("installTestLibrary", KlibInstall) {
|
|||||||
|
|
||||||
void konanc(String[] args) {
|
void konanc(String[] args) {
|
||||||
def konancScript = isWindows() ? "konanc.bat" : "konanc"
|
def konancScript = isWindows() ? "konanc.bat" : "konanc"
|
||||||
def konanc = "$dist/bin/$konancScript"
|
def konanc = "$kotlinNativeDist/bin/$konancScript"
|
||||||
def allArgs = args.join(" ")
|
def allArgs = args.join(" ")
|
||||||
println("$konanc $allArgs")
|
println("$konanc $allArgs")
|
||||||
"$konanc $allArgs".execute().waitFor()
|
"$konanc $allArgs".execute().waitFor()
|
||||||
@@ -4421,7 +4413,7 @@ if (PlatformInfo.isAppleTarget(project)) {
|
|||||||
standaloneTest("jsinterop_math") {
|
standaloneTest("jsinterop_math") {
|
||||||
doBeforeBuild {
|
doBeforeBuild {
|
||||||
def jsinteropScript = isWindows() ? "jsinterop.bat" : "jsinterop"
|
def jsinteropScript = isWindows() ? "jsinterop.bat" : "jsinterop"
|
||||||
def jsinterop = "$dist/bin/$jsinteropScript"
|
def jsinterop = "$kotlinNativeDist/bin/$jsinteropScript"
|
||||||
// TODO: We probably need a NativeInteropPlugin for jsinterop?
|
// TODO: We probably need a NativeInteropPlugin for jsinterop?
|
||||||
"$jsinterop -pkg kotlinx.interop.wasm.math -o $buildDir/jsmath -target wasm32".execute().waitFor()
|
"$jsinterop -pkg kotlinx.interop.wasm.math -o $buildDir/jsmath -target wasm32".execute().waitFor()
|
||||||
|
|
||||||
@@ -5224,7 +5216,7 @@ project.tasks.register("debugger_test", Test.class) {
|
|||||||
enabled = (target.family == Family.OSX) // KT-30366
|
enabled = (target.family == Family.OSX) // KT-30366
|
||||||
testLogging { exceptionFormat = 'full' }
|
testLogging { exceptionFormat = 'full' }
|
||||||
UtilsKt.dependsOnDist(it)
|
UtilsKt.dependsOnDist(it)
|
||||||
systemProperties = ['kotlin.native.home': dist]
|
systemProperties = ['kotlin.native.home': kotlinNativeDist]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure build for iOS device targets.
|
// Configure build for iOS device targets.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.gradle.api.Task
|
|||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.jetbrains.kotlin.konan.target.AppleConfigurables
|
import org.jetbrains.kotlin.konan.target.AppleConfigurables
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.tasks.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test task for -Xcoverage and -Xlibraries-to-cover flags. Requires a binary to be built by the Konan plugin
|
* Test task for -Xcoverage and -Xlibraries-to-cover flags. Requires a binary to be built by the Konan plugin
|
||||||
@@ -64,7 +65,11 @@ open class CoverageTest : DefaultTask() {
|
|||||||
override fun configure(closure: Closure<Any>): Task {
|
override fun configure(closure: Closure<Any>): Task {
|
||||||
super.configure(closure)
|
super.configure(closure)
|
||||||
dependsOnDist()
|
dependsOnDist()
|
||||||
dependsOn(project.tasks.getByName("compileKonan$binaryName"))
|
val compileBinaryTask = project.tasks.getByName("compileKonan$binaryName")
|
||||||
|
compileBinaryTask.konanOldPluginTaskDependenciesWalker{
|
||||||
|
dependsOnDist()
|
||||||
|
}
|
||||||
|
dependsOn(compileBinaryTask)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
@@ -4,7 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.kotlin
|
package org.jetbrains.kotlin
|
||||||
|
|
||||||
|
import groovy.lang.Closure
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.jetbrains.kotlin.klib.metadata.CInteropComparisonConfig
|
import org.jetbrains.kotlin.klib.metadata.CInteropComparisonConfig
|
||||||
@@ -58,6 +60,12 @@ open class MetadataComparisonTest : DefaultTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun configure(closure: Closure<Any>): Task {
|
||||||
|
super.configure(closure)
|
||||||
|
dependsOnDist()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
private fun cinterop(defFile: File, mode: Mode): File {
|
private fun cinterop(defFile: File, mode: Mode): File {
|
||||||
val dist = project.kotlinNativeDist
|
val dist = project.kotlinNativeDist
|
||||||
val output = "${project.buildDir.absolutePath}/${defFile.nameWithoutExtension}_$mode"
|
val output = "${project.buildDir.absolutePath}/${defFile.nameWithoutExtension}_$mode"
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ val Project.platformManager
|
|||||||
val Project.testTarget
|
val Project.testTarget
|
||||||
get() = findProperty("target") as KonanTarget
|
get() = findProperty("target") as KonanTarget
|
||||||
|
|
||||||
|
val Project.testTargetSuffix
|
||||||
|
get() = (findProperty("target") as KonanTarget ?: HostManager.host).name.capitalize()
|
||||||
|
|
||||||
val Project.verboseTest
|
val Project.verboseTest
|
||||||
get() = hasProperty("test_verbose")
|
get() = hasProperty("test_verbose")
|
||||||
|
|
||||||
@@ -48,8 +51,32 @@ val Project.testOutputExternal
|
|||||||
get() = (findProperty("testOutputExternal") as File).toString()
|
get() = (findProperty("testOutputExternal") as File).toString()
|
||||||
|
|
||||||
val Project.kotlinNativeDist
|
val Project.kotlinNativeDist
|
||||||
get() = this.rootProject.file(this.findProperty("org.jetbrains.kotlin.native.home")
|
get() = this.rootProject.file(findProperty("kotlin.native.home")
|
||||||
?: this.findProperty("konan.home") ?: "dist")
|
?: findProperty("org.jetbrains.kotlin.native.home")
|
||||||
|
?: findProperty("konan.home") ?: "dist")
|
||||||
|
|
||||||
|
val Project.useCustomDist
|
||||||
|
get() = hasProperty("kotlin.native.home") ||
|
||||||
|
hasProperty("org.jetbrains.kotlin.native.home") ||
|
||||||
|
hasProperty("konan.home")
|
||||||
|
|
||||||
|
private val libraryRegexp = Regex("""^import\s+platform\.(\S+)\..*$""")
|
||||||
|
fun File.dependencies() =
|
||||||
|
readLines().filter(libraryRegexp::containsMatchIn)
|
||||||
|
.map { libraryRegexp.matchEntire(it)?.groups?.get(1)?.value ?: "" }
|
||||||
|
.toSortedSet()
|
||||||
|
|
||||||
|
|
||||||
|
fun Task.dependsOnPlatformLibs() {
|
||||||
|
val platformManager = project.project(":kotlin-native").platformManager
|
||||||
|
val target = project.testTarget ?: platformManager.hostPlatform.target
|
||||||
|
(this as? KonanTest)?.run {
|
||||||
|
project.file(source).dependencies().forEach {
|
||||||
|
this.dependsOn(":kotlin-native:platformLibs:${target.name}-$it")
|
||||||
|
//this.dependsOn(":kotlin-native:platformLibs:${target.name}-${it}Cache")
|
||||||
|
}
|
||||||
|
} ?: error("unsupported task : $this")
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val Project.globalTestArgs: List<String>
|
val Project.globalTestArgs: List<String>
|
||||||
@@ -105,19 +132,27 @@ fun Project.dependsOnDist(taskName: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Task.dependsOnDist() {
|
fun Task.dependsOnDist() {
|
||||||
val rootTasks = project.rootProject.tasks
|
|
||||||
// We don't build the compiler if a custom dist path is specified.
|
// We don't build the compiler if a custom dist path is specified.
|
||||||
if (!(project.findProperty("useCustomDist") as Boolean)) {
|
if (!(project.findProperty("useCustomDist") as Boolean)) {
|
||||||
dependsOn(rootTasks.getByName("dist"))
|
dependsOn(":kotlin-native:dist")
|
||||||
val target = project.testTarget
|
val target = project.testTarget
|
||||||
if (target != HostManager.host) {
|
if (target != HostManager.host) {
|
||||||
// if a test_target property is set then tests should depend on a crossDist
|
// if a test_target property is set then tests should depend on a crossDist
|
||||||
// otherwise, runtime components would not be build for a target.
|
// otherwise, runtime components would not be build for a target.
|
||||||
dependsOn(rootTasks.getByName("${target.name}CrossDist"))
|
dependsOn(":kotlin-native:${target.name}CrossDist")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Task.konanOldPluginTaskDependenciesWalker(index:Int = 0, walker: Task.(Int)->Unit) {
|
||||||
|
walker(index + 1)
|
||||||
|
dependsOn.forEach{
|
||||||
|
val task = (it as? Task) ?: return@forEach
|
||||||
|
if (task.name.startsWith("compileKonan"))
|
||||||
|
task.konanOldPluginTaskDependenciesWalker(index + 1, walker)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the same dependencies for the receiver task from the given [task]
|
* Sets the same dependencies for the receiver task from the given [task]
|
||||||
*/
|
*/
|
||||||
@@ -140,7 +175,9 @@ fun Task.sameDependenciesAs(task: Task) {
|
|||||||
*/
|
*/
|
||||||
fun Task.dependsOnKonanBuildingTask(artifact: String, target: KonanTarget) {
|
fun Task.dependsOnKonanBuildingTask(artifact: String, target: KonanTarget) {
|
||||||
val buildTask = project.findKonanBuildTask(artifact, target)
|
val buildTask = project.findKonanBuildTask(artifact, target)
|
||||||
buildTask.dependsOnDist()
|
buildTask.konanOldPluginTaskDependenciesWalker {
|
||||||
|
dependsOnDist()
|
||||||
|
}
|
||||||
buildTask.sameDependenciesAs(this)
|
buildTask.sameDependenciesAs(this)
|
||||||
dependsOn(buildTask)
|
dependsOn(buildTask)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user