[build] Use gradle plugin in backend.native tests
This commit is contained in:
@@ -17,7 +17,25 @@
|
||||
import groovy.json.JsonOutput
|
||||
import org.jetbrains.kotlin.*
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url kotlinCompilerRepo
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin"
|
||||
}
|
||||
ext.useCustomDist = project.hasProperty("konan.home")
|
||||
if (!useCustomDist) {
|
||||
ext.setProperty("konan.home", distDir.absolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: NativeInteropPlugin
|
||||
apply plugin: 'konan'
|
||||
|
||||
configurations {
|
||||
cli_bc
|
||||
@@ -68,34 +86,19 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
def konanHome = rootProject.file(project.findProperty("konan.home") ?: distDir).absolutePath
|
||||
def suffix = isWindows() ? ".bat" : ""
|
||||
|
||||
// TODO: Ideally we want to write just konanArtifacts{} clause here,
|
||||
// but we need to make Kotlin/Native Gradle Plugin a dependence
|
||||
// of our buildScripts first.
|
||||
task compileKonanTestLibrary(type: Exec) {
|
||||
if (!project.hasProperty("konan.home")) {
|
||||
dependsOn ':dist'
|
||||
konanArtifacts {
|
||||
library('testLibrary') {
|
||||
if (!useCustomDist) {
|
||||
dependsOn ':dist'
|
||||
}
|
||||
srcDir 'testLibrary'
|
||||
}
|
||||
|
||||
def compiler = "$konanHome/bin/konanc$suffix"
|
||||
def source = 'testLibrary'
|
||||
def artifact = 'build/konan/bin/testLibrary'
|
||||
|
||||
executable compiler
|
||||
args source, '-o', artifact, '-p', 'library'
|
||||
}
|
||||
|
||||
task installTestLibrary(type: Exec) {
|
||||
dependsOn 'compileKonanTestLibrary'
|
||||
|
||||
def tool = "$konanHome/bin/klib$suffix"
|
||||
def repo = "$konanHome/klib/common"
|
||||
def library = 'build/konan/bin/testLibrary.klib'
|
||||
|
||||
executable tool
|
||||
args 'install', library, '-repository', repo
|
||||
task installTestLibrary(type: KlibInstall) {
|
||||
dependsOn compileKonanTestLibraryHost
|
||||
klib = konanArtifacts.testLibrary.getArtifactByTarget('host')
|
||||
repo = rootProject.file("${project.property("konan.home")}/klib/common")
|
||||
}
|
||||
|
||||
// TODO: use lastSuccessful teamcity build.
|
||||
@@ -130,7 +133,7 @@ task update_external_tests() {
|
||||
}
|
||||
}
|
||||
|
||||
task clean {
|
||||
clean {
|
||||
doLast {
|
||||
delete(rootProject.file(testOutputRoot))
|
||||
}
|
||||
@@ -142,7 +145,7 @@ def tasksOf(Closure<Task> filter) {
|
||||
.matching { filter(it) && it.enabled && (prefix != null ? it.name.startsWith(prefix) : true) }
|
||||
}
|
||||
|
||||
task run() {
|
||||
run {
|
||||
def tasks = tasksOf { it instanceof RunKonanTest && !(it instanceof RunStdlibTest) }
|
||||
dependsOn(tasks)
|
||||
}
|
||||
@@ -1310,7 +1313,7 @@ task link_omit_unused(type: LinkKonanTest) {
|
||||
}
|
||||
|
||||
task link_default_libs(type: RunStandaloneKonanTest) {
|
||||
if (!project.hasProperty("konan.home")) {
|
||||
if (!useCustomDist) {
|
||||
dependsOn ':distPlatformLibs'
|
||||
}
|
||||
disabled = (project.testTarget == 'wasm32') // there will be no posix.klib for wasm
|
||||
@@ -1331,7 +1334,7 @@ task link_testLib_explicitly(type: RunStandaloneKonanTest) {
|
||||
}
|
||||
|
||||
task no_purge_for_dependencies(type: LinkKonanTest) {
|
||||
if (!project.hasProperty("konan.home")) {
|
||||
if (!useCustomDist) {
|
||||
dependsOn ':distPlatformLibs'
|
||||
}
|
||||
disabled = (project.testTarget == 'wasm32') // there will be no posix.klib for wasm
|
||||
@@ -2328,7 +2331,7 @@ task interop_echo_server(type: RunInteropKonanTest) {
|
||||
|
||||
if (isMac()) {
|
||||
task interop_opengl_teapot(type: RunStandaloneKonanTest) {
|
||||
if (!project.hasProperty("konan.home")) {
|
||||
if (!useCustomDist) {
|
||||
dependsOn ':distPlatformLibs'
|
||||
}
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
|
||||
@@ -17,14 +17,21 @@
|
||||
apply plugin: 'groovy'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
ext.rootBuildDirectory = "$rootDir/.."
|
||||
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
|
||||
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile gradleApi()
|
||||
compile localGroovy()
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion"
|
||||
compile group: 'com.ullink.slack', name: 'simpleslackapi', version: '0.6.0'
|
||||
// An artifact from the included build 'shared' cannot be used here due to https://github.com/gradle/gradle/issues/3768
|
||||
// TODO: Remove this hack when the bug is fixed
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.Exec
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.TargetManager
|
||||
import java.io.File
|
||||
|
||||
// TODO: Implement as a part of the gradle plugin
|
||||
open class KlibInstall: Exec() {
|
||||
@InputFile
|
||||
lateinit var klib: File
|
||||
var repo: File = project.rootDir
|
||||
|
||||
val installDir: File
|
||||
@OutputDirectory
|
||||
get() {
|
||||
val klibName = klib.name.take(klib.name.lastIndexOf('.'))
|
||||
return project.file("${repo.absolutePath}/$klibName")
|
||||
}
|
||||
|
||||
@Input
|
||||
var target: String = TargetManager.hostName
|
||||
|
||||
override fun configure(config: Closure<*>): Task {
|
||||
val result = super.configure(config)
|
||||
val konanHome = project.rootProject.file(project.findProperty("konan.home") ?: "dist")
|
||||
val suffix = if (TargetManager.host == KonanTarget.MINGW) ".bat" else ""
|
||||
val klibProgram = "$konanHome/bin/klib$suffix"
|
||||
|
||||
doFirst {
|
||||
repo.mkdirs()
|
||||
|
||||
commandLine(klibProgram,
|
||||
"install", klib.absolutePath,
|
||||
"-target", target,
|
||||
"-repository", repo.absolutePath
|
||||
)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.KlibInstall
|
||||
import org.jetbrains.kotlin.konan.target.TargetManager
|
||||
import org.jetbrains.kotlin.konan.util.DefFile
|
||||
|
||||
@@ -50,41 +50,6 @@ private String targetToOs(String target) {
|
||||
private String defFileToLibName(String target, String name) {
|
||||
return "$target-$name".toString()
|
||||
}
|
||||
|
||||
// TODO: Implement as a part of the gradle plugin
|
||||
class KlibInstall extends Exec {
|
||||
@InputFile
|
||||
public File klib
|
||||
public File repo
|
||||
|
||||
@Input
|
||||
public String target
|
||||
|
||||
@Override
|
||||
Task configure(Closure config) {
|
||||
super.configure(config)
|
||||
|
||||
def konanHome = project.property("konan.home")
|
||||
def suffix = (TargetManager.host == KonanTarget.MINGW) ? ".bat" : ""
|
||||
def klibProgram = "$konanHome/bin/klib$suffix"
|
||||
|
||||
doFirst {
|
||||
repo.mkdirs()
|
||||
|
||||
commandLine klibProgram,
|
||||
'install', klib.absolutePath,
|
||||
'-target', target,
|
||||
'-repository', repo.absolutePath
|
||||
}
|
||||
}
|
||||
|
||||
@OutputDirectory
|
||||
File getInstallDir() {
|
||||
def klibName = klib.name.take(klib.name.lastIndexOf('.'))
|
||||
return project.file("$repo.absolutePath/$klibName")
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
targetList.each { target ->
|
||||
|
||||
Reference in New Issue
Block a user