-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add graalVM native image support for desktop Platforms. * Fix bunnymark project Co-authored-by: Cedric Hippmann <[email protected]>
- Loading branch information
Showing
32 changed files
with
1,190 additions
and
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## Default GraalVM native image configuration | ||
|
||
!!! warning | ||
Reloading code changes in the editor is not possible with native-image, as it would require to reload the JVM. | ||
|
||
On desktop platform, you can choose to build a [GraalVM native image](https://www.graalvm.org/reference-manual/native-image/). You first need to install graal-vm and its tool native image. Then, you should set `GRAALVM_HOME` environment variable to point to GraalVM's home folder. | ||
|
||
On windows, you should add `VC_VARS_PATH` environment variable to point to vcvars bat file. This is mandatory so that we can initialize visual studio tools. (Example: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat`) | ||
|
||
In order to build a native image, you should add configuration to gradle plugin to enable building of native-image this way: | ||
```kotlin | ||
godot { | ||
isGraalExportEnabled.set(true) | ||
nativeImageToolPath.set("${System.getenv("GRAALVM_HOME")}/bin/native-image") | ||
|
||
windowsDeveloperVCVarsPath.set("System.getenv("VC_VARS_PATH")") | ||
} | ||
``` | ||
|
||
In order to use the generated native-image, you can pass `--java-vm-type=graal` argument to engine, or simply change `godot_kotlin_configuration.json` to set vm_type to `graal`. | ||
|
||
## Reflection, libraries and JNI with native image | ||
|
||
GraalVM native image performs AOT compilation. In order to be able to use reflection and jni, you need to provide an additional configuration file. | ||
This applies also for third party library you use that would do reflection. You can find documentation on how to easily generate them [here](https://www.graalvm.org/reference-manual/native-image/Agent/). | ||
|
||
In order to append those configurations add the json in `graal` folder of your project (it should be generated on first graal native image use). Then you can add `additionalGraalJniConfigurationFiles` parameter, this way: | ||
|
||
```kotlin | ||
godot { | ||
isGraalExportEnabled.set(true) | ||
nativeImageToolPath.set("${System.getenv("GRAALVM_HOME")}/bin/native-image") | ||
|
||
windowsDeveloperVCVarsPath.set(System.getenv("VC_VARS_PATH")) | ||
additionalGraalJniConfigurationFiles.set(arrayOf("my-jni-configuration-file.json", "another-conf.json")) | ||
} | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,3 +490,5 @@ hs_err_pid* | |
build/ | ||
|
||
/.gradle/ | ||
|
||
graal/godot-kotlin-graal-jni-config.json |
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
|
||
plugins { | ||
kotlin("jvm") version "1.4.32" | ||
kotlin("jvm") version "1.5.21" | ||
id("com.utopia-rise.godot-kotlin-jvm") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
godot { | ||
//uncomment to test graal vm native image | ||
// isGraalNativeImageExportEnabled.set(true) | ||
// nativeImageToolPath.set("${System.getenv("GRAALVM_HOME")}/bin/native-image") | ||
// windowsDeveloperVCVarsPath.set(System.getenv("VC_VARS_PATH")) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
|
||
# Ignore Gradle build output directory | ||
build | ||
|
||
graal/godot-kotlin-graal-jni-config.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"vm_type":"jvm"} |
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
5 changes: 5 additions & 0 deletions
5
...le-plugin/src/main/kotlin/godot/gradle/exception/GraalNativeImageToolNotFountException.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,5 @@ | ||
package godot.gradle.exception | ||
|
||
class GraalNativeImageToolNotFountException: IllegalArgumentException( | ||
"native-image tool not set! Make sure you've either set the GRAALVM_HOME environment variable or set the nativeImageToolPath. For more information, visit: https://godot-kotl.in/en/stable/user-guide/advanced/graal-vm-native-image" | ||
) |
Oops, something went wrong.