Build: Fix kotlin-native tasks input annotations
Required for Gradle 7+ #KTI-559
This commit is contained in:
@@ -13,7 +13,7 @@ open class CopyCommonSources : DefaultTask() {
|
||||
var zipSources: Boolean = false
|
||||
|
||||
@InputFiles
|
||||
var sourcePaths: ConfigurableFileCollection = project.files()
|
||||
val sourcePaths: ConfigurableFileCollection = project.files()
|
||||
|
||||
@OutputDirectory
|
||||
var outputDir: File = project.buildDir.resolve("sources")
|
||||
@@ -27,7 +27,7 @@ open class CopyCommonSources : DefaultTask() {
|
||||
}
|
||||
|
||||
fun sourcePaths(paths: Any) {
|
||||
sourcePaths = project.files(paths)
|
||||
sourcePaths.setFrom(paths)
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.jetbrains.kotlin.konan.target.AppleConfigurables
|
||||
|
||||
/**
|
||||
@@ -49,6 +50,7 @@ open class CoverageTest : DefaultTask() {
|
||||
@Input
|
||||
var numberOfCoveredLines: Int? = null
|
||||
|
||||
@get:Internal
|
||||
val profrawFile: String by lazy {
|
||||
"${project.buildDir.absolutePath}/$binaryName.profraw"
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.file.FileTree
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.Optional
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
@@ -42,6 +43,7 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
@Input
|
||||
var codesign: Boolean = true
|
||||
|
||||
@Input
|
||||
val testOutput: String = project.testOutputFramework
|
||||
|
||||
@Input @Optional
|
||||
@@ -100,13 +102,17 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
this.map { language.filesFrom(it) }
|
||||
.flatMap { it.files }
|
||||
|
||||
@get:Internal
|
||||
override val executable: String
|
||||
get() = Paths.get(testOutput, name, "swiftTestExecutable").toString()
|
||||
|
||||
@Internal
|
||||
override var doBeforeRun: Action<in Task>? = null
|
||||
|
||||
@Internal
|
||||
override var doBeforeBuild: Action<in Task>? = null
|
||||
|
||||
@get:Internal
|
||||
override val buildTasks: List<Task>
|
||||
get() = frameworks.map { project.tasks.getByName("compileKonan${it.name}") }
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.Exec
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
@@ -16,9 +17,13 @@ open class KlibInstall: Exec() {
|
||||
@Input
|
||||
lateinit var klib: Provider<File>
|
||||
|
||||
@Input
|
||||
@Internal
|
||||
var repo: File = project.rootDir
|
||||
|
||||
@get:Input
|
||||
val repoPath
|
||||
get() = repo.absolutePath
|
||||
|
||||
val installDir: Provider<File>
|
||||
@OutputDirectory
|
||||
get() = project.provider {
|
||||
|
||||
+15
-14
@@ -31,6 +31,7 @@ abstract class KonanTest : DefaultTask(), KonanTestExecutable {
|
||||
SILENT // Prints no log of passed/failed tests
|
||||
}
|
||||
|
||||
@get:Input
|
||||
var disabled: Boolean
|
||||
get() = !enabled
|
||||
set(value) {
|
||||
@@ -40,11 +41,13 @@ abstract class KonanTest : DefaultTask(), KonanTestExecutable {
|
||||
/**
|
||||
* Test output directory. Used to store processed sources and binary artifacts.
|
||||
*/
|
||||
@get:OutputDirectory
|
||||
abstract val outputDirectory: String
|
||||
|
||||
/**
|
||||
* Test logger to be used for the test built with TestRunner (`-tr` option).
|
||||
*/
|
||||
@get:Internal
|
||||
abstract var testLogger: Logger
|
||||
|
||||
/**
|
||||
@@ -61,6 +64,7 @@ abstract class KonanTest : DefaultTask(), KonanTestExecutable {
|
||||
/**
|
||||
* Test source.
|
||||
*/
|
||||
@Internal
|
||||
lateinit var source: String
|
||||
|
||||
/**
|
||||
@@ -74,14 +78,13 @@ abstract class KonanTest : DefaultTask(), KonanTestExecutable {
|
||||
* As this run task comes after the build task all actions for doFirst
|
||||
* should be done before the build and not run.
|
||||
*/
|
||||
@Input
|
||||
@Optional
|
||||
@Internal
|
||||
override var doBeforeBuild: Action<in Task>? = null
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
@Internal
|
||||
override var doBeforeRun: Action<in Task>? = null
|
||||
|
||||
@get:Internal
|
||||
override val buildTasks: List<Task>
|
||||
get() = listOf(project.findKonanBuildTask(name, project.testTarget))
|
||||
|
||||
@@ -151,9 +154,11 @@ open class KonanGTest : KonanTest() {
|
||||
// Use GTEST logger to parse test results later
|
||||
override var testLogger = Logger.GTEST
|
||||
|
||||
@get:Internal
|
||||
override val executable: String
|
||||
get() = "$outputDirectory/${project.testTarget.name}/$name.${project.testTarget.family.exeSuffix}"
|
||||
|
||||
@Internal
|
||||
var statistics = Statistics()
|
||||
|
||||
@TaskAction
|
||||
@@ -199,6 +204,7 @@ open class KonanLocalTest : KonanTest() {
|
||||
override val outputDirectory = project.testOutputLocal
|
||||
|
||||
// local tests built into a single binary with the known name
|
||||
@get:Internal
|
||||
override val executable: String
|
||||
get() = "$outputDirectory/${project.testTarget.name}/localTest.${project.testTarget.family.exeSuffix}"
|
||||
|
||||
@@ -208,15 +214,13 @@ open class KonanLocalTest : KonanTest() {
|
||||
@Optional
|
||||
var expectedExitStatus: Int? = null
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
@Internal
|
||||
var expectedExitStatusChecker: (Int) -> Boolean = { it == (expectedExitStatus ?: 0) }
|
||||
|
||||
/**
|
||||
* Should this test fail or not.
|
||||
*/
|
||||
@Input
|
||||
@Optional
|
||||
var expectedFail = false
|
||||
|
||||
/**
|
||||
@@ -252,8 +256,7 @@ open class KonanLocalTest : KonanTest() {
|
||||
/**
|
||||
* Checks test's output against gold value and returns true if the output matches the expectation.
|
||||
*/
|
||||
@Input
|
||||
@Optional
|
||||
@Internal
|
||||
var outputChecker: (String) -> Boolean = { output ->
|
||||
if (useGoldenData) goldenData == output else true
|
||||
}
|
||||
@@ -287,11 +290,9 @@ open class KonanLocalTest : KonanTest() {
|
||||
* Should compiler message be read and validated with output checker or gold value.
|
||||
*/
|
||||
@Input
|
||||
@Optional
|
||||
var compilerMessages = false
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
var multiRuns = false
|
||||
|
||||
@Input
|
||||
@@ -388,16 +389,15 @@ open class KonanStandaloneTest : KonanLocalTest() {
|
||||
get() = "$outputDirectory/${project.testTarget.name}/$name.${project.testTarget.family.exeSuffix}"
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
var enableKonanAssertions = true
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
var verifyIr = true
|
||||
|
||||
/**
|
||||
* Compiler flags used to build a test.
|
||||
*/
|
||||
@Internal
|
||||
var flags: List<String> = listOf()
|
||||
get() {
|
||||
val result = field.toMutableList()
|
||||
@@ -408,6 +408,7 @@ open class KonanStandaloneTest : KonanLocalTest() {
|
||||
return result
|
||||
}
|
||||
|
||||
@Internal
|
||||
fun getSources(): Provider<List<String>> = project.provider {
|
||||
val sources = buildCompileList(project.file(source).toPath(), outputDirectory)
|
||||
sources.forEach { it.writeTextToFile() }
|
||||
@@ -490,7 +491,7 @@ open class KonanDynamicTest : KonanStandaloneTest() {
|
||||
/**
|
||||
* File path to the C source.
|
||||
*/
|
||||
@Input
|
||||
@get:Input
|
||||
lateinit var cSource: String
|
||||
|
||||
@Input
|
||||
|
||||
+11
-5
@@ -17,10 +17,10 @@ import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
open class CompileToBitcode @Inject constructor(
|
||||
val srcRoot: File,
|
||||
val folderName: String,
|
||||
val target: String,
|
||||
val outputGroup: String
|
||||
@Internal val srcRoot: File,
|
||||
@Input val folderName: String,
|
||||
@Input val target: String,
|
||||
@Input val outputGroup: String
|
||||
) : DefaultTask() {
|
||||
|
||||
enum class Language {
|
||||
@@ -28,22 +28,27 @@ open class CompileToBitcode @Inject constructor(
|
||||
}
|
||||
|
||||
// Compiler args are part of compilerFlags so we don't register them as an input.
|
||||
@Internal
|
||||
val compilerArgs = mutableListOf<String>()
|
||||
@Input
|
||||
val linkerArgs = mutableListOf<String>()
|
||||
@Input
|
||||
var excludeFiles: List<String> = listOf(
|
||||
"**/*Test.cpp",
|
||||
"**/*TestSupport.cpp",
|
||||
"**/*Test.mm",
|
||||
"**/*TestSupport.mm"
|
||||
)
|
||||
@Input
|
||||
var includeFiles: List<String> = listOf(
|
||||
"**/*.cpp",
|
||||
"**/*.mm"
|
||||
)
|
||||
|
||||
// Source files and headers are registered as inputs by the `inputFiles` and `headers` properties.
|
||||
@Internal
|
||||
var srcDirs: FileCollection = project.files(srcRoot.resolve("cpp"))
|
||||
@Internal
|
||||
var headersDirs: FileCollection = srcDirs + project.files(srcRoot.resolve("headers"))
|
||||
|
||||
@Input
|
||||
@@ -62,13 +67,14 @@ open class CompileToBitcode @Inject constructor(
|
||||
return project.buildDir.resolve("bitcode/$outputGroup/$target$sanitizerSuffix")
|
||||
}
|
||||
|
||||
@get:Input
|
||||
@get:Internal
|
||||
val objDir
|
||||
get() = File(targetDir, folderName)
|
||||
|
||||
private val KonanTarget.isMINGW
|
||||
get() = this.family == Family.MINGW
|
||||
|
||||
@get:Internal
|
||||
val executable
|
||||
get() = when (language) {
|
||||
Language.C -> "clang"
|
||||
|
||||
+5
-3
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.testing.native
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.options.Option
|
||||
import org.gradle.process.ExecResult
|
||||
@@ -23,9 +24,9 @@ import javax.inject.Inject
|
||||
*/
|
||||
@Suppress("UnstableApiUsage")
|
||||
open class GitDownloadTask @Inject constructor(
|
||||
val repositoryProvider: Provider<URL>,
|
||||
val revisionProvider: Provider<String>,
|
||||
val outputDirectoryProvider: Provider<File>
|
||||
private val repositoryProvider: Provider<URL>,
|
||||
private val revisionProvider: Provider<String>,
|
||||
private val outputDirectoryProvider: Provider<File>
|
||||
) : DefaultTask() {
|
||||
|
||||
private val repository: URL
|
||||
@@ -40,6 +41,7 @@ open class GitDownloadTask @Inject constructor(
|
||||
@Option(option = "refresh",
|
||||
description = "Fetch and checkout the revision even if the output directory already contains it. " +
|
||||
"All changes in the output directory will be overwritten")
|
||||
@Input
|
||||
val refresh: Property<Boolean> = project.objects.property(Boolean::class.java).apply {
|
||||
set(false)
|
||||
}
|
||||
|
||||
+3
-4
@@ -29,7 +29,6 @@ open class CompileNativeTest @Inject constructor(
|
||||
@Input @Optional
|
||||
var sanitizer: SanitizerKind? = null
|
||||
|
||||
@Input
|
||||
private val sanitizerFlags = when (sanitizer) {
|
||||
null -> listOf()
|
||||
SanitizerKind.ADDRESS -> listOf("-fsanitize=address")
|
||||
@@ -55,14 +54,14 @@ open class CompileNativeTest @Inject constructor(
|
||||
}
|
||||
|
||||
open class LlvmLinkNativeTest @Inject constructor(
|
||||
val baseName: String,
|
||||
baseName: String,
|
||||
@Input val target: String,
|
||||
@InputFile val mainFile: File
|
||||
) : DefaultTask() {
|
||||
|
||||
@SkipWhenEmpty
|
||||
@InputFiles
|
||||
var inputFiles: ConfigurableFileCollection = project.files()
|
||||
val inputFiles: ConfigurableFileCollection = project.files()
|
||||
|
||||
@OutputFile
|
||||
var outputFile: File = project.buildDir.resolve("bitcode/test/$target/$baseName.bc")
|
||||
@@ -265,7 +264,7 @@ private fun createTestTask(
|
||||
testName, target, testSupportTask.outFile
|
||||
).apply {
|
||||
val tasksToLink = (compileToBitcodeTasks + testedTasks + testFrameworkTasks)
|
||||
inputFiles = project.files(tasksToLink.map { it.outFile })
|
||||
inputFiles.setFrom(tasksToLink.map { it.outFile })
|
||||
dependsOn(testSupportTask)
|
||||
dependsOn(tasksToLink)
|
||||
}
|
||||
|
||||
@@ -30,8 +30,10 @@ buildscript {
|
||||
class NativeDep extends DefaultTask {
|
||||
static final String baseUrl = "https://cache-redirector.jetbrains.com/download.jetbrains.com/kotlin/native"
|
||||
|
||||
@Internal
|
||||
KonanPropertiesLoader konanPropertiesLoader = null
|
||||
|
||||
@Internal
|
||||
final File getBaseOutDir() {
|
||||
final File res = project.rootProject.project(":kotlin-native").ext.dependenciesDir
|
||||
res.mkdirs()
|
||||
|
||||
Reference in New Issue
Block a user