Skip to content

Commit

Permalink
CPP reloading (#621)
Browse files Browse the repository at this point in the history
* Make GDKotlin states even more granular to prepare for reloading.
* Unregister all jni binding when terminating gdkotlin.
* Disable JVM reloading
* Add Jar loading

---------

Co-authored-by: chippmann <[email protected]>
  • Loading branch information
CedNaru and chippmann authored Oct 14, 2024
1 parent 4151313 commit 117b671
Show file tree
Hide file tree
Showing 58 changed files with 728 additions and 1,516 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ jobs:
run: |
cd modules/kotlin_jvm/harness/tests/
chmod +x ../../../../bin/godot.*
jlink --add-modules java.base,java.logging --output jre-amd64-linux
jlink --add-modules java.base,java.logging --output jvm/jre-amd64-linux
./gradlew runGutTests
timeout-minutes: 30
2 changes: 1 addition & 1 deletion .github/workflows/test_linux_exports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Create JRE
run: |
cd harness/tests/
jlink --add-modules java.base,java.logging --output jre-amd64-linux
jlink --add-modules java.base,java.logging --output jvm/jre-amd64-linux
- name: Export tests debug
if: ${{ matrix.bootstrap-target == 'debug' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ jobs:
run: |
cd modules/kotlin_jvm/harness/tests/
chmod +x ../../../../bin/godot.*
jlink --add-modules java.base,java.logging --output jre-arm64-macos
jlink --add-modules java.base,java.logging --output jvm/jre-arm64-macos
./gradlew runGutTests
timeout-minutes: 30
4 changes: 2 additions & 2 deletions .github/workflows/test_macos_exports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ jobs:
- name: Create JRE
run: |
cd harness/tests/
jlink --add-modules java.base,java.logging --output jre-arm64-macos
mkdir jre-amd64-macos #create a fake jre dir for amd64 so the export is happy. The test will run on arm anyways
jlink --add-modules java.base,java.logging --output jvm/jre-arm64-macos
mkdir jvm/jre-amd64-macos #create a fake jre dir for amd64 so the export is happy. The test will run on arm anyways
- name: Export tests debug
if: ${{ matrix.bootstrap-target == 'debug' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ jobs:
- name: Run Tests
run: |
cd modules/kotlin_jvm/harness/tests/
jlink --add-modules java.base,java.logging --output jre-amd64-windows
jlink --add-modules java.base,java.logging --output jvm/jre-amd64-windows
./gradlew runGutTests
timeout-minutes: 30
2 changes: 1 addition & 1 deletion .github/workflows/test_windows_exports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Create JRE
run: |
cd harness/tests/
jlink --add-modules java.base,java.logging --output jre-amd64-windows
jlink --add-modules java.base,java.logging --output jvm/jre-amd64-windows
- name: Export tests debug
if: ${{ matrix.bootstrap-target == 'debug' }}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_compile_definitions(DEV_ENABLED)
# platforms
#add_compile_definitions(WINDOWS_ENABLED)
add_compile_definitions(X11_ENABLED)
#add_compile_definitions(OSX_ENABLED)
#add_compile_definitions(MACOS_ENABLED)
#add_compile_definitions(IOS_ENABLED)
#add_compile_definitions(__ANDROID__)

Expand Down
4 changes: 2 additions & 2 deletions docs/src/doc/contribution/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ scons platform=linuxbsd # your target platform (windows, macos, ...)
1. Navigate to `<module-root>/harness/tests`
2. Create an embedded Java Virtual Machine:
- For `amd64` systems:
- `jlink --add-modules java.base,java.logging --output jre-amd64-<platform ex. linux>`
- `jlink --add-modules java.base,java.logging --output jvm/jre-amd64-<platform ex. linux>`
- For `arm64` (macOS with **Apple Silicon** chips) systems:
- `jlink --add-modules java.base,java.logging --output jre-arm64-<platform ex. macos>`
- `jlink --add-modules java.base,java.logging --output jvm/jre-arm64-<platform ex. macos>`
- If you want to remote debug add module `jdk.jdwp.agent` to command.
- If you want to enable `jmx`, add `jdk.management.agent` to command.
3. Then build the project using the Gradle wrapper.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/doc/user-guide/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ In order to debug your code using an embedded JRE, make sure to include the foll
- `jdk.jdwp.agent`

!!! info
Example for AMD64 systems: `jlink --add-modules java.base,java.logging,jdk.jdwp.agent --output jre-amd64-linux` (make sure to swap `linux` to your platform!)
Example for ARM64 systems: `jlink --add-modules java.base,java.logging,jdk.jdwp.agent --output jre-arm64-macos` (make sure to swap `macos` to your platform!)
Example for AMD64 systems: `jlink --add-modules java.base,java.logging,jdk.jdwp.agent --output jvm/jre-amd64-linux` (make sure to swap `linux` to your platform!)
Example for ARM64 systems: `jlink --add-modules java.base,java.logging,jdk.jdwp.agent --output jvm/jre-arm64-macos` (make sure to swap `macos` to your platform!)

If you're still using the JDK installed on your system though, you don't need to do this.

Expand Down
12 changes: 6 additions & 6 deletions docs/src/doc/user-guide/exporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ To export your game, you need to have an embedded JRE created. Run the following

- amd64 systems:
```shell
jlink --add-modules java.base,java.logging --output jre-amd64-linux
jlink --add-modules java.base,java.logging --output jvm/jre-amd64-linux
```
- arm64 systems:
```shell
jlink --add-modules java.base,java.logging --output jre-arm64-macos
jlink --add-modules java.base,java.logging --output jvm/jre-arm64-macos
```

!!! info
As the jre is platform dependent, you need to create a jre for each platform. Adjust the above command on a per-platform basis:
- For Linux: `jre-amd64-linux`
- For Windows: `jre-amd64-windows`
- For Linux: `jvm/jre-amd64-linux`
- For Windows: `jvm/jre-amd64-windows`
- For MacOS:
- `jre-amd64-macos`
- `jre-arm64-macos`
- `jvm/jre-amd64-macos`
- `jvm/jre-arm64-macos`
- For iOS and Android, no embedded JRE is needed

The above command will create a very minimal JVM, if you need extra features you can include the following modules:
Expand Down
Loading

0 comments on commit 117b671

Please sign in to comment.