gradle-plugin: Minor naming fixes
* Rename: input{Files,Dir} -> src{Files,Dir}
* Rename: pkg -> packageName
* remove allLibrariesFrom(projectPath: String)
This commit is contained in:
@@ -7,7 +7,7 @@ konanArtifacts {
|
||||
|
||||
interop ('sdl') {
|
||||
defFile 'src/main/c_interop/sdl.def'
|
||||
pkg 'sdl'
|
||||
packageName 'sdl'
|
||||
|
||||
target 'macbook', {
|
||||
includeDirs '/Library/Frameworks/SDL2.framework/Headers',
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ abstract class KonanBuildingConfig<T: KonanBuildingTask>(private val name_: Stri
|
||||
val target = TargetManager(targetString).target
|
||||
|
||||
if (!target.enabled) {
|
||||
project.logger.info("Target '$targetString' of artifact '$name' is not supported on the current host")
|
||||
project.logger.warn("Target '$targetString' of artifact '$name' is not supported on the current host")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -28,16 +28,16 @@ abstract class KonanCompileConfig<T: KonanCompileTask>(name: String,
|
||||
override fun generateHostTaskDescription(task: Task, hostTarget: KonanTarget) =
|
||||
"Build the Kotlin/Native $typeForDescription '${task.name}' for current host"
|
||||
|
||||
override fun inputDir(dir: Any) = forEach { it.inputDir(dir) }
|
||||
override fun inputFiles(vararg files: Any) = forEach { it.inputFiles(*files) }
|
||||
override fun inputFiles(files: Collection<Any>) = forEach { it.inputFiles(files) }
|
||||
override fun srcDir(dir: Any) = forEach { it.srcDir(dir) }
|
||||
override fun srcFiles(vararg files: Any) = forEach { it.srcFiles(*files) }
|
||||
override fun srcFiles(files: Collection<Any>) = forEach { it.srcFiles(files) }
|
||||
|
||||
override fun nativeLibrary(lib: Any) = forEach { it.nativeLibrary(lib) }
|
||||
override fun nativeLibraries(vararg libs: Any) = forEach { it.nativeLibraries(*libs) }
|
||||
override fun nativeLibraries(libs: FileCollection) = forEach { it.nativeLibraries(libs) }
|
||||
|
||||
override fun linkerOpts(args: List<String>) = forEach { it.linkerOpts(args) }
|
||||
override fun linkerOpts(vararg args: String) = forEach { it.linkerOpts(*args) }
|
||||
override fun linkerOpts(values: List<String>) = forEach { it.linkerOpts(values) }
|
||||
override fun linkerOpts(vararg values: String) = forEach { it.linkerOpts(*values) }
|
||||
|
||||
override fun languageVersion(version: String) = forEach { it.languageVersion(version) }
|
||||
override fun apiVersion(version: String) = forEach { it.apiVersion(version) }
|
||||
|
||||
+2
-1
@@ -27,7 +27,7 @@ open class KonanInteropLibrary(name: String, project: ProjectInternal, instantia
|
||||
|
||||
override fun defFile(file: Any) = forEach { it.defFile(file) }
|
||||
|
||||
override fun pkg(value: String) = forEach { it.pkg(value) }
|
||||
override fun packageName(value: String) = forEach { it.packageName(value) }
|
||||
|
||||
override fun compilerOpts(vararg values: String) = forEach { it.compilerOpts(*values) }
|
||||
|
||||
@@ -38,6 +38,7 @@ open class KonanInteropLibrary(name: String, project: ProjectInternal, instantia
|
||||
override fun includeDirs(vararg values: Any) = forEach { it.includeDirs(*values) }
|
||||
|
||||
override fun linkerOpts(values: List<String>) = forEach { it.linkerOpts(values) }
|
||||
override fun linkerOpts(vararg values: String) = linkerOpts(values.toList())
|
||||
|
||||
override fun link(vararg files: Any) = forEach { it.link(*files) }
|
||||
override fun link(files: FileCollection) = forEach { it.link(files) }
|
||||
|
||||
+2
-6
@@ -96,15 +96,11 @@ open class KonanLibrariesSpec(val task: KonanArtifactWithLibrariesTask, val proj
|
||||
fun allLibrariesFrom(vararg libraryProjects: Project) = allArtifactsFromInternal(libraryProjects) {
|
||||
it is KonanLibrary || it is KonanInteropLibrary
|
||||
}
|
||||
/** All libraries (both interop and non-interop ones) from the projects by paths */
|
||||
fun allLibrariesFrom(vararg paths: String) = allLibrariesFrom(*paths.map { project.project(it) }.toTypedArray())
|
||||
|
||||
/** All interop libraries from the projects by direct references */
|
||||
fun allInteropsFrom(vararg libraryProjects: Project) = allArtifactsFromInternal(libraryProjects) {
|
||||
fun allInteropLibrariesFrom(vararg libraryProjects: Project) = allArtifactsFromInternal(libraryProjects) {
|
||||
it is KonanInteropLibrary
|
||||
}
|
||||
/** All interop libraries from the projects by paths */
|
||||
fun allInteropsFrom(vararg paths: String) = allInteropsFrom(*paths.map { project.project(it) }.toTypedArray())
|
||||
|
||||
/** Add repo for library search */
|
||||
fun useRepo(directory: Any) = explicitRepos.add(project.file(directory))
|
||||
@@ -113,7 +109,7 @@ open class KonanLibrariesSpec(val task: KonanArtifactWithLibrariesTask, val proj
|
||||
/** Add repos for library search */
|
||||
fun useRepos(directories: Iterable<Any>) = directories.forEach { useRepo(it) }
|
||||
|
||||
fun Project.evaluationDependsOn(another: Project) {
|
||||
private fun Project.evaluationDependsOn(another: Project) {
|
||||
if (this != another) { evaluationDependsOn(another.path) }
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -20,7 +20,6 @@ import org.gradle.api.*
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.api.plugins.BasePlugin
|
||||
import org.gradle.api.tasks.TaskCollection
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanPlugin.Companion.COMPILE_ALL_TASK_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.*
|
||||
@@ -82,7 +81,9 @@ internal val Project.konanVersion
|
||||
get() = getProperty(KonanPlugin.ProjectProperty.KONAN_VERSION, KonanPlugin.DEFAULT_KONAN_VERSION) as String
|
||||
|
||||
internal val Project.requestedTargets
|
||||
get() = findProperty(KonanPlugin.ProjectProperty.KONAN_BUILD_TARGETS)?.toString()?.trim()?.split(' ') ?: emptyList()
|
||||
get() = findProperty(KonanPlugin.ProjectProperty.KONAN_BUILD_TARGETS)?.let {
|
||||
it.toString().trim().split("\\s+".toRegex())
|
||||
}.orEmpty()
|
||||
|
||||
internal val Project.compileAllTask
|
||||
get() = getOrCreateTask(COMPILE_ALL_TASK_NAME)
|
||||
@@ -163,7 +164,7 @@ internal fun dumpProperties(task: Task) {
|
||||
println("Compilation task: ${name}")
|
||||
println("destinationDir : ${destinationDir}")
|
||||
println("artifact : ${artifact.canonicalPath}")
|
||||
println("inputFiles : ${inputFiles.dump()}")
|
||||
println("srcFiles : ${srcFiles.dump()}")
|
||||
println("produce : ${produce}")
|
||||
println("libraries : ${libraries.files.dump()}")
|
||||
println(" : ${libraries.artifacts.map {
|
||||
@@ -197,7 +198,7 @@ internal fun dumpProperties(task: Task) {
|
||||
println(" : ${libraries.namedKlibs.dump()}")
|
||||
println("defFile : ${defFile}")
|
||||
println("target : ${target}")
|
||||
println("pkg : ${pkg}")
|
||||
println("packageName : ${packageName}")
|
||||
println("compilerOpts : ${compilerOpts}")
|
||||
println("linkerOpts : ${linkerOpts}")
|
||||
println("headers : ${headers.dump()}")
|
||||
|
||||
+7
-7
@@ -24,10 +24,10 @@ interface KonanBuildingSpec: KonanArtifactWithLibrariesSpec {
|
||||
}
|
||||
|
||||
interface KonanCompileSpec: KonanBuildingSpec {
|
||||
fun inputDir(dir: Any)
|
||||
fun srcDir(dir: Any)
|
||||
|
||||
fun inputFiles(vararg files: Any)
|
||||
fun inputFiles(files: Collection<Any>)
|
||||
fun srcFiles(vararg files: Any)
|
||||
fun srcFiles(files: Collection<Any>)
|
||||
|
||||
// DSL. Native libraries.
|
||||
|
||||
@@ -37,8 +37,8 @@ interface KonanCompileSpec: KonanBuildingSpec {
|
||||
|
||||
// DSL. Other parameters.
|
||||
|
||||
fun linkerOpts(args: List<String>)
|
||||
fun linkerOpts(vararg args: String)
|
||||
fun linkerOpts(vararg values: String)
|
||||
fun linkerOpts(values: List<String>)
|
||||
|
||||
fun languageVersion(version: String)
|
||||
fun apiVersion(version: String)
|
||||
@@ -56,7 +56,7 @@ interface KonanInteropSpec: KonanBuildingSpec {
|
||||
|
||||
fun defFile(file: Any)
|
||||
|
||||
fun pkg(value: String)
|
||||
fun packageName(value: String)
|
||||
|
||||
fun compilerOpts(vararg values: String)
|
||||
|
||||
@@ -66,7 +66,7 @@ interface KonanInteropSpec: KonanBuildingSpec {
|
||||
|
||||
fun includeDirs(vararg values: Any)
|
||||
|
||||
fun linkerOpts(vararg values: String) = linkerOpts(values.toList())
|
||||
fun linkerOpts(vararg values: String)
|
||||
fun linkerOpts(values: List<String>)
|
||||
|
||||
fun link(vararg files: Any)
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.kotlin.gradle.plugin.tasks
|
||||
|
||||
import org.gradle.api.tasks.Console
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
@@ -16,7 +17,7 @@ abstract class KonanBuildingTask: KonanArtifactWithLibrariesTask(), KonanBuildin
|
||||
super.init(destinationDir, artifactName, target)
|
||||
}
|
||||
|
||||
@Input
|
||||
@Console
|
||||
var dumpParameters: Boolean = false
|
||||
|
||||
@Input
|
||||
|
||||
+12
-12
@@ -45,9 +45,9 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
|
||||
// Other compilation parameters -------------------------------------------
|
||||
|
||||
internal val _inputFiles = mutableSetOf<FileCollection>()
|
||||
val inputFiles: Collection<FileCollection>
|
||||
@InputFiles get() = _inputFiles.takeIf { !it.isEmpty() } ?: listOf(project.konanDefaultSrcFiles)
|
||||
protected val srcFiles_ = mutableSetOf<FileCollection>()
|
||||
val srcFiles: Collection<FileCollection>
|
||||
@InputFiles get() = srcFiles_.takeIf { !it.isEmpty() } ?: listOf(project.konanDefaultSrcFiles)
|
||||
|
||||
@InputFiles val nativeLibraries = mutableSetOf<FileCollection>()
|
||||
|
||||
@@ -98,23 +98,23 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
|
||||
addAll(extraOpts)
|
||||
|
||||
inputFiles.flatMap { it.files }.filter { it.name.endsWith(".kt") }.mapTo(this) { it.canonicalPath }
|
||||
srcFiles.flatMap { it.files }.filter { it.name.endsWith(".kt") }.mapTo(this) { it.canonicalPath }
|
||||
}
|
||||
|
||||
// region DSL.
|
||||
|
||||
// DSL. Input/output files.
|
||||
|
||||
override fun inputDir(dir: Any) {
|
||||
_inputFiles.add(project.fileTree(dir).apply {
|
||||
override fun srcDir(dir: Any) {
|
||||
srcFiles_.add(project.fileTree(dir).apply {
|
||||
include("**/*.kt")
|
||||
exclude { it.file.startsWith(project.buildDir) }
|
||||
})
|
||||
}
|
||||
override fun inputFiles(vararg files: Any) {
|
||||
_inputFiles.add(project.files(files))
|
||||
override fun srcFiles(vararg files: Any) {
|
||||
srcFiles_.add(project.files(files))
|
||||
}
|
||||
override fun inputFiles(files: Collection<Any>) = inputFiles(*files.toTypedArray())
|
||||
override fun srcFiles(files: Collection<Any>) = srcFiles(*files.toTypedArray())
|
||||
|
||||
// DSL. Native libraries.
|
||||
|
||||
@@ -128,9 +128,9 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
|
||||
// DSL. Other parameters.
|
||||
|
||||
override fun linkerOpts(args: List<String>) = linkerOpts(*args.toTypedArray())
|
||||
override fun linkerOpts(vararg args: String) {
|
||||
linkerOpts.addAll(args)
|
||||
override fun linkerOpts(values: List<String>) = linkerOpts(*values.toTypedArray())
|
||||
override fun linkerOpts(vararg values: String) {
|
||||
linkerOpts.addAll(values)
|
||||
}
|
||||
|
||||
override fun languageVersion(version: String) {
|
||||
|
||||
+4
-4
@@ -43,7 +43,7 @@ open class KonanInteropTask: KonanBuildingTask(), KonanInteropSpec {
|
||||
|
||||
@InputFile lateinit var defFile: File
|
||||
|
||||
@Optional @Input var pkg: String? = null
|
||||
@Optional @Input var packageName: String? = null
|
||||
|
||||
@Input val compilerOpts = mutableListOf<String>()
|
||||
@Input val linkerOpts = mutableListOf<String>()
|
||||
@@ -58,7 +58,7 @@ open class KonanInteropTask: KonanBuildingTask(), KonanInteropSpec {
|
||||
|
||||
addArgIfNotNull("-target", target.userName)
|
||||
addArgIfNotNull("-def", defFile.canonicalPath)
|
||||
addArgIfNotNull("-pkg", pkg)
|
||||
addArgIfNotNull("-pkg", packageName)
|
||||
|
||||
addFileArgs("-h", headers)
|
||||
|
||||
@@ -91,8 +91,8 @@ open class KonanInteropTask: KonanBuildingTask(), KonanInteropSpec {
|
||||
defFile = project.file(file)
|
||||
}
|
||||
|
||||
override fun pkg(value: String) {
|
||||
pkg = value
|
||||
override fun packageName(value: String) {
|
||||
packageName = value
|
||||
}
|
||||
|
||||
override fun compilerOpts(vararg values: String) {
|
||||
|
||||
Reference in New Issue
Block a user