gradle-plugin: Make def-file mandatory and remove 'linker' parameter
This commit is contained in:
-1
@@ -65,7 +65,6 @@ import java.io.File
|
||||
*/
|
||||
|
||||
|
||||
// TODO: form groups for tasks
|
||||
// TODO: Make the task class nested for config with properties accessible for outer users.
|
||||
open class KonanCompileTask: KonanTargetableTask() {
|
||||
|
||||
|
||||
+8
-9
@@ -70,13 +70,13 @@ open class KonanInteropTask: KonanTargetableTask() {
|
||||
|
||||
// Interop stub generator parameters -------------------------------------
|
||||
|
||||
@Optional @InputFile var defFile: File? = null
|
||||
@InputFile var defFile: File? = null
|
||||
internal set
|
||||
|
||||
@Optional @Input var pkg: String? = null
|
||||
internal set
|
||||
@Input lateinit var libName: String
|
||||
|
||||
@Optional @Input var linker: String? = null
|
||||
@Input lateinit var libName: String
|
||||
internal set
|
||||
|
||||
@Optional @Input var manifest: String? = null
|
||||
@@ -123,7 +123,6 @@ open class KonanInteropTask: KonanTargetableTask() {
|
||||
addArgIfNotNull("-target", target)
|
||||
addArgIfNotNull("-def", defFile?.canonicalPath)
|
||||
addArg("-pkg", pkg ?: libName)
|
||||
addArgIfNotNull("-linker", linker)
|
||||
|
||||
addFileArgs("-h", headers)
|
||||
|
||||
@@ -175,7 +174,11 @@ open class KonanInteropConfig(
|
||||
// DSL methods ------------------------------------------------------------
|
||||
|
||||
fun defFile(file: Any) = with(generateStubsTask) {
|
||||
defFile = project.file(file)
|
||||
defFile = project.file(file).also {
|
||||
if (!it.exists()) {
|
||||
throw NoSuchFileException(it, reason = "No def-file by the specified path.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun pkg(value: String) = with(generateStubsTask) {
|
||||
@@ -204,10 +207,6 @@ open class KonanInteropConfig(
|
||||
compilerOpts.addAll(values.map { "-I$it" })
|
||||
}
|
||||
|
||||
fun linker(value: String) = with(generateStubsTask) {
|
||||
linker = value
|
||||
}
|
||||
|
||||
fun linkerOpts(vararg values: String) = linkerOpts(values.toList())
|
||||
fun linkerOpts(values: List<String>) = with(generateStubsTask) {
|
||||
linkerOpts.addAll(values)
|
||||
|
||||
+5
-4
@@ -57,8 +57,8 @@ internal val Project.konanInteropCompiledStubsDir get() = "${konanBuildRoot}/int
|
||||
internal val Project.konanInteropLibsOutputDir get() = "${konanBuildRoot}/nativelibs"
|
||||
|
||||
internal val Project.konanDefaultSrcDir get() = file("${projectDir.canonicalPath}/src/main/kotlin")
|
||||
internal fun Project.konanDefaultDefFile(interopName: String)
|
||||
= file("${projectDir.canonicalPath}/src/main/c_interop/$interopName.def")
|
||||
internal fun Project.konanDefaultDefFile(libName: String)
|
||||
= file("${projectDir.canonicalPath}/src/main/c_interop/$libName.def")
|
||||
|
||||
internal val Project.konanInteropClasspath
|
||||
get() = project.fileTree("${project.konanHome}/konan/lib/").apply { include("*.jar") }
|
||||
@@ -157,8 +157,10 @@ internal fun dumpProperties(task: Task) {
|
||||
println()
|
||||
println("Compilation task: ${task.name}")
|
||||
println("outputDir : ${task.outputDir}")
|
||||
println("artifact : ${task.artifact}")
|
||||
println("artifactPath : ${task.artifactPath}")
|
||||
println("inputFiles : ${task.inputFiles.joinToString(prefix = "[", separator = ", ", postfix = "]")}")
|
||||
println("produce : ${task.produce}")
|
||||
println("libraries : ${task.libraries}")
|
||||
println("nativeLibraries : ${task.nativeLibraries}")
|
||||
println("linkerOpts : ${task.linkerOpts}")
|
||||
@@ -180,7 +182,6 @@ internal fun dumpProperties(task: Task) {
|
||||
println("defFile : ${task.defFile}")
|
||||
println("target : ${task.target}")
|
||||
println("pkg : ${task.pkg}")
|
||||
println("linker : ${task.linker}")
|
||||
println("compilerOpts : ${task.compilerOpts}")
|
||||
println("linkerOpts : ${task.linkerOpts}")
|
||||
println("headers : ${task.headers.joinToString(prefix = "[", separator = ", ", postfix = "]")}")
|
||||
@@ -197,7 +198,7 @@ internal fun setDefaultInputs(project: Project) {
|
||||
project.konanArtifactsContainer.asSequence()
|
||||
.filter { it.compilationTask.inputFiles.isEmpty() }
|
||||
.forEach { config ->
|
||||
project.konanDefaultSrcDir?.takeIf { it.exists() }?.let {
|
||||
project.konanDefaultSrcDir.takeIf { it.exists() }?.let {
|
||||
config.inputDir(it.canonicalPath)
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -166,6 +166,7 @@ class IncrementalSpecification extends BaseKonanSpecification {
|
||||
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
|
||||
it.generateSrcFile('main.kt')
|
||||
it.buildFile.append("konanInterop { foo {} }\n")
|
||||
it.generateDefFile("foo.def", "")
|
||||
}
|
||||
def results = buildTwice(project) { KonanInteropProject it ->
|
||||
it.addCompilationSetting("main", "useInterop", "'foo'")
|
||||
|
||||
+1
@@ -311,6 +311,7 @@ class KonanInteropProject extends KonanProject {
|
||||
generateFolders()
|
||||
generateBuildFile()
|
||||
generatePropertiesFile(konanHome)
|
||||
generateDefFile("${DEFAULT_INTEROP_NAME}.def", "")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user