[Gradle] Added definitionFile RegularFileProperty in cinterop task
^KT-62795 Fixed Merge-request: KT-MR-13307 Merged-by: Dmitrii Krasnov <Dmitrii.Krasnov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
f1b6c2df45
commit
331ec5318d
+22
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.native
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.condition.OS
|
||||
|
||||
@NativeGradlePluginTests
|
||||
@@ -53,4 +54,25 @@ class CinteropIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-62795: checking that we can pass def file to cinterop task as a output file property from another task")
|
||||
@GradleTest
|
||||
fun cinteropWithDefFileFromTaskOutput(gradleVersion: GradleVersion) {
|
||||
nativeProject("cinterop-with-def-creation-task", gradleVersion = gradleVersion) {
|
||||
|
||||
val defFilePath = projectPath.resolve("def/cinterop.def").toFile().canonicalFile.absolutePath
|
||||
|
||||
build(":assemble") {
|
||||
assertTasksUpToDate(":createDefFileTask") // this task does not have any action, so it always just UpToDate
|
||||
extractNativeTasksCommandLineArgumentsFromOutput(":cinteropCinteropNative", toolName = NativeToolKind.C_INTEROP) {
|
||||
assertCommandLineArgumentsContainSequentially("-def", defFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
build(":assemble") {
|
||||
assertTasksUpToDate(":createDefFileTask")
|
||||
assertTasksUpToDate(":cinteropCinteropNative")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
val createDefFileTask = project.tasks.register("createDefFileTask", CreateDefFileTask::class) {
|
||||
defFile.set(project.layout.buildDirectory.file(project.file("def/cinterop.def").absolutePath))
|
||||
}
|
||||
|
||||
kotlin {
|
||||
<SingleNativeTarget>("native") {
|
||||
binaries {
|
||||
executable()
|
||||
}
|
||||
compilations.getByName("main") {
|
||||
cinterops {
|
||||
val cinterop by creating {
|
||||
definitionFile.set(createDefFileTask.flatMap { it.defFile })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
|
||||
abstract class CreateDefFileTask : DefaultTask() {
|
||||
|
||||
@get:OutputFile
|
||||
abstract val defFile: RegularFileProperty
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package = my.cinterop
|
||||
---
|
||||
|
||||
static int foo() {
|
||||
return 42;
|
||||
}
|
||||
Reference in New Issue
Block a user