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