Skip to content

Commit

Permalink
Merge pull request #75 from Over-Run/native-image
Browse files Browse the repository at this point in the history
feat: add support to GraalVM Native Image
  • Loading branch information
squid233 authored Jan 26, 2025
1 parent 71855bc commit 9089662
Show file tree
Hide file tree
Showing 2,481 changed files with 185,696 additions and 246,348 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ The latest Javadoc can be found [here](https://over-run.github.io/overrungl/).

The documentation of OpenGL can be found from [Khronos' references](https://registry.khronos.org/OpenGL-Refpages/gl4/) and [docs.gl](https://docs.gl/).

[JavaPoet](https://github.com/palantir/javapoet) is used to generate source files.

### Credits

[<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" alt="JetBrains Logo (Main) logo." width="128" height="128">](https://jb.gg/OpenSourceSupport)
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/generator.conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
plugins { kotlin("jvm") }

val javaPoetVersion: String by rootProject
val kotlinTargetJdkVersion: String by rootProject

repositories {
mavenCentral()
}

dependencies {
implementation("com.palantir.javapoet:javapoet:$javaPoetVersion")
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/generators.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ fun Project.registerGenerateTask(main: String, targetProject: String) {
tasks.register<GenerateTask>("generate") {
mainClass.set(main)
workingDir = project(targetProject).projectDir.resolve("src/main/java/")
args(projectDir)
}
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/module.conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ val jdkEnablePreview: String by rootProject

val targetJavaVersion = jdkVersion.toInt()

val graalvmVersion: String by rootProject
val jetbrainsAnnotationsVersion: String by rootProject
val junitVersion: String by rootProject

Expand All @@ -47,6 +48,8 @@ repositories {

dependencies {
compileOnly("org.jetbrains:annotations:$jetbrainsAnnotationsVersion")
compileOnly("org.graalvm.sdk:nativeimage:$graalvmVersion")
//compileOnly("org.graalvm.nativeimage:svm:$graalvmVersion")
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
Expand Down
4 changes: 3 additions & 1 deletion generators/core/src/main/kotlin/overrungl/MemoryStack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fun memoryStack() {
val src = Files.readString(path)
val sb = StringBuilder()

sb.append(" ")
sb.appendLine(formatter_off)

Type.entries.forEach {
Expand All @@ -51,13 +52,14 @@ fun memoryStack() {
| /// @param values the values
| /// @return the allocated segment
| public MemorySegment ${it.methodName}(${it.typeName}... values) {
| return Marshal.marshal(this, values);
| return MemoryUtil.allocArray(this, values);
| }
|
""".trimMargin()
)
}

sb.append(" ")
sb.appendLine(formatter_on)

writeString(path, replaceCode(src, sb.toString()))
Expand Down
Loading

0 comments on commit 9089662

Please sign in to comment.