Skip to content

Commit

Permalink
Add includes property to dumpIncludes task
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaracha committed Sep 27, 2024
1 parent 7ecbe5e commit addf1e5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ abstract class GradleJextractPlugin : Plugin<Project> {
dumpIncludesTask.configure { task ->
val config = project.objects.newInstance(DumpIncludesTask.LibraryConfig::class.java).apply {
header.set(lib.header)
includes.set(lib.includes)
argFile.set(project.layout.buildDirectory.file("reports/jextract/${lib.name}-includes.txt"))
}
task.libraries.add(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class DownloadTask : DefaultTask() {
private val client: HttpClient = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).version(HttpClient.Version.HTTP_1_1).build()

@TaskAction
fun download() {
protected fun download() {
val url = resource.get().url
val checksum = resource.get().checksum
val algorithm = resource.get().algorithm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package de.infolektuell.gradle.jextract.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.file.Directory
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.*
import org.gradle.process.ExecOperations
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
Expand All @@ -18,10 +17,13 @@ abstract class DumpIncludesTask @Inject constructor(private val workerExecutor:
interface LibraryConfig {
@get:InputFile
val header: RegularFileProperty
@get:InputFiles
val includes: ListProperty<Directory>
@get:OutputFile
val argFile: RegularFileProperty
}
abstract class DumpIncludesAction @Inject constructor(private val execOperations: ExecOperations) : WorkAction<DumpIncludesAction.Parameters> {

protected abstract class DumpIncludesAction @Inject constructor(private val execOperations: ExecOperations) : WorkAction<DumpIncludesAction.Parameters> {
interface Parameters : WorkParameters {
val executable: RegularFileProperty
val library: Property<LibraryConfig>
Expand All @@ -30,6 +32,7 @@ abstract class DumpIncludesTask @Inject constructor(private val workerExecutor:
execOperations.exec { spec ->
spec.executable(parameters.executable.get().asFile.absolutePath)
parameters.library.get().run {
includes.get().forEach { spec.args("-I", it.asFile.absolutePath) }
spec.args("--dump-includes", argFile.get().asFile.absolutePath)
spec.args(header.get().asFile.absolutePath)
}
Expand All @@ -43,7 +46,7 @@ abstract class DumpIncludesTask @Inject constructor(private val workerExecutor:
abstract val libraries: SetProperty<LibraryConfig>

@TaskAction
fun dump() {
protected fun dump() {
val queue = workerExecutor.noIsolation()
libraries.get().forEach { config ->
queue.submit(DumpIncludesAction::class.java) { param ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class ExtractTask @Inject constructor(private val fileSystem: FileSyste
@get:OutputDirectory
abstract val target: DirectoryProperty
@TaskAction
fun run() {
protected fun extract() {
fileSystem.delete { spec ->
spec.delete(target)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract class GenerateBindingsTask @Inject constructor(private val workerExecut
val sources: DirectoryProperty
}

abstract class GenerateBindingsAction @Inject constructor(private val fileSystemOperations: FileSystemOperations, private val execOperations: ExecOperations) : WorkAction<GenerateBindingsAction.Parameters> {
protected abstract class GenerateBindingsAction @Inject constructor(private val fileSystemOperations: FileSystemOperations, private val execOperations: ExecOperations) : WorkAction<GenerateBindingsAction.Parameters> {
interface Parameters : WorkParameters {
val executable: RegularFileProperty
val library: Property<LibraryConfig>
Expand Down Expand Up @@ -80,7 +80,7 @@ abstract class GenerateBindingsTask @Inject constructor(private val workerExecut
@get:Nested
abstract val libraries: SetProperty<LibraryConfig>
@TaskAction
fun generateBindings() {
protected fun generateBindings() {
val queue = workerExecutor.noIsolation()
libraries.get().forEach { lib ->
queue.submit(GenerateBindingsAction::class.java) { param ->
Expand Down

0 comments on commit addf1e5

Please sign in to comment.