-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Vulkan video extensions
- Loading branch information
Showing
24 changed files
with
15,415 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
generator/src/main/kotlin/com/kylemayes/generator/generate/file/Headers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.kylemayes.generator.generate.file | ||
|
||
import com.kylemayes.generator.support.bindgen | ||
import com.kylemayes.generator.support.time | ||
import mu.KotlinLogging | ||
import kotlin.io.path.ExperimentalPathApi | ||
import kotlin.io.path.createTempDirectory | ||
import kotlin.io.path.deleteRecursively | ||
import kotlin.io.path.writeText | ||
|
||
private val log = KotlinLogging.logger { /* */ } | ||
|
||
/** Generates a Rust module using `bindgen` for a collection of C/C++ headers. */ | ||
@OptIn(ExperimentalPathApi::class) | ||
fun generateHeaders(name: String, headers: Map<String, String>, options: List<String> = emptyList()): String { | ||
if (headers.isEmpty()) { | ||
return "" | ||
} | ||
|
||
val tmp = createTempDirectory("vk-headers") | ||
headers.forEach { tmp.resolve(it.key).writeText(it.value) } | ||
|
||
val input = tmp.resolve("__input.h") | ||
input.writeText(headers.keys.joinToString("\n") { "#include \"$it\"" }) | ||
|
||
val bindings = log.time("Generate Headers ($name)") { | ||
bindgen( | ||
"--verbose", | ||
"--rust-target=1.64", | ||
"--use-core", | ||
"--no-layout-tests", | ||
*options.toTypedArray(), | ||
input.toString(), | ||
) | ||
} | ||
|
||
tmp.deleteRecursively() | ||
|
||
return bindings | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.