Don't create run tasks for non-host targets
This commit is contained in:
+1
-1
@@ -481,7 +481,7 @@ open class KotlinNativeTargetConfigurator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Project.createRunTask(binary: Executable) {
|
private fun Project.createRunTask(binary: Executable) {
|
||||||
val taskName = binary.runTaskName
|
val taskName = binary.runTaskName ?: return
|
||||||
// TODO provide a special exec task for tests.
|
// TODO provide a special exec task for tests.
|
||||||
tasks.create(taskName, Exec::class.java).apply {
|
tasks.create(taskName, Exec::class.java).apply {
|
||||||
if (binary.isDefaultTestExecutable) {
|
if (binary.isDefaultTestExecutable) {
|
||||||
|
|||||||
+23
-17
@@ -11,10 +11,10 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.api.tasks.AbstractExecTask
|
import org.gradle.api.tasks.AbstractExecTask
|
||||||
import org.gradle.util.ConfigureUtil
|
import org.gradle.util.ConfigureUtil
|
||||||
import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator
|
import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator
|
||||||
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinNativeCompile
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
|
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
|
||||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||||
import org.jetbrains.kotlin.konan.target.Family
|
import org.jetbrains.kotlin.konan.target.Family
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +102,7 @@ class Executable constructor(
|
|||||||
get() = super.baseName
|
get() = super.baseName
|
||||||
set(value) {
|
set(value) {
|
||||||
super.baseName = value
|
super.baseName = value
|
||||||
runTask.executable = outputFile.absolutePath
|
runTask?.executable = outputFile.absolutePath
|
||||||
}
|
}
|
||||||
|
|
||||||
var entryPoint: String? = null
|
var entryPoint: String? = null
|
||||||
@@ -111,23 +111,29 @@ class Executable constructor(
|
|||||||
entryPoint = point
|
entryPoint = point
|
||||||
}
|
}
|
||||||
|
|
||||||
val runTaskName: String
|
/**
|
||||||
get() = if (isDefaultTestExecutable) {
|
* A name of task running this executable.
|
||||||
lowerCamelCaseName(compilation.target.targetName, AbstractKotlinTargetConfigurator.testTaskNameSuffix)
|
* Returns null if the executables's target is not a host one (macosX64, linuxX64 or mingw64).
|
||||||
} else {
|
*/
|
||||||
lowerCamelCaseName("run", name, compilation.target.targetName)
|
val runTaskName: String?
|
||||||
|
get() {
|
||||||
|
if (target.konanTarget !in listOf(KonanTarget.MACOS_X64, KonanTarget.LINUX_X64, KonanTarget.MINGW_X64)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return if (isDefaultTestExecutable) {
|
||||||
|
lowerCamelCaseName(compilation.target.targetName, AbstractKotlinTargetConfigurator.testTaskNameSuffix)
|
||||||
|
} else {
|
||||||
|
lowerCamelCaseName("run", name, compilation.target.targetName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val runTask: AbstractExecTask<*>
|
/**
|
||||||
get() = project.tasks.getByName(runTaskName) as AbstractExecTask<*>
|
* A task running this executable.
|
||||||
|
* Returns null if the executables's target is not a host one (macosX64, linuxX64 or mingw64).
|
||||||
fun runTask(configure: AbstractExecTask<*>.() -> Unit) {
|
*/
|
||||||
runTask.configure()
|
val runTask: AbstractExecTask<*>?
|
||||||
}
|
get() = runTaskName?.let { project.tasks.getByName(it) as AbstractExecTask<*> }
|
||||||
|
|
||||||
fun runTask(configure: Closure<*>) {
|
|
||||||
ConfigureUtil.configure(configure, runTask)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class StaticLibrary(
|
class StaticLibrary(
|
||||||
|
|||||||
Reference in New Issue
Block a user