Skip to content

Commit 8fb3e10

Browse files
EnaiumDeepSeek
andauthored
feat(native): add Windows ARM64 support (#443)
Add a windowsarm64 target to generateLibs using the LLVM-MinGW clang wrappers, with a shared createWindowsTarget() helper keeping the existing x86_64 path intact. LLVM-MinGW builds against libc++, which does not pull <exception> transitively, so patch imgui-node-editor's crude_json.cpp through the existing vendor patch flow. Bundle the LWJGL natives-windows-arm64 classifiers in imgui-app and document the direct Gradle build path. Co-authored-by: DeepSeek <noreply@deepseek.com>
1 parent f13ec24 commit 8fb3e10

5 files changed

Lines changed: 51 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,15 @@ If you don't need FreeType or want a stock build under the project tree, call `g
421421
- Build: `./gradlew imgui-binding:generateLibs -Denvs=windows -Dlocal`
422422
- Run example: `./gradlew example:run -PlibPath="../imgui-binding/build/libsNative/windows64"`
423423

424+
### Windows ARM64
425+
426+
- Required on PATH: Ant, [LLVM-MinGW](https://github.com/mstorsjo/llvm-mingw) (the `aarch64-w64-mingw32-*`
427+
wrappers).
428+
- Build: `./gradlew imgui-binding:generateLibs -Denvs=windowsarm64 -Dlocal`
429+
- Output: `imgui-binding/build/libsNative/windowsarm64/imgui-java64.dll`
430+
- Run example: `./gradlew example:run -PlibPath="../imgui-binding/build/libsNative/windowsarm64"`
431+
- The direct Gradle path builds without FreeType by default, matching the other platforms.
432+
424433
### Linux
425434

426435
- Install dependencies: `mingw-w64-gcc`, `ant`. (Package names vary by distro.)
@@ -439,7 +448,7 @@ If you don't need FreeType or want a stock build under the project tree, call `g
439448

440449
| Flag | Effect |
441450
|-------------------|-------------------------------------------------------------------------------------------------------------------------------|
442-
| `-Denvs=<csv>` | Target platforms — any of `windows`, `linux`, `macos`, `macosarm64` |
451+
| `-Denvs=<csv>` | Target platforms — any of `windows`, `windowsarm64`, `linux`, `linuxarm64`, `macos`, `macosarm64` |
443452
| `-Dlocal` | Output to `imgui-binding/build/libsNative/` instead of `/tmp/imgui/` |
444453
| `-Dfreetype=true` | Compile FreeType statically into the binary (requires `vendor_freetype.sh` to have been run; `build.sh` handles this for you) |
445454

‎buildSrc/scripts/apply_vendor_patches.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ apply_patch_idempotent() {
3030
apply_patch_idempotent \
3131
"$(pwd)/patches/imgui-node-editor-imgui-1.92-operator-star.patch" \
3232
include/imgui-node-editor
33+
34+
# LLVM-MinGW's libc++ does not transitively include <exception>, so the
35+
# Windows ARM64 build needs the explicit include for std::terminate().
36+
apply_patch_idempotent \
37+
"$(pwd)/patches/imgui-node-editor-libcxx-exception.patch" \
38+
include/imgui-node-editor

‎buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class GenerateLibs extends DefaultTask {
3131

3232
private final String[] buildEnvs = System.getProperty('envs')?.split(',')
3333
private final boolean forWindows = buildEnvs?.contains('windows')
34+
private final boolean forWindowsArm64 = buildEnvs?.contains('windowsarm64')
3435
private final boolean forLinux = buildEnvs?.contains('linux')
3536
private final boolean forLinuxArm64 = buildEnvs?.contains('linuxarm64')
3637
private final boolean forMac = buildEnvs?.contains('macos')
@@ -114,10 +115,11 @@ class GenerateLibs extends DefaultTask {
114115
BuildTarget[] buildTargets = []
115116

116117
if (forWindows) {
117-
def win64 = BuildTarget.newDefaultTarget(Os.Windows, Architecture.Bitness._64)
118-
requireCpp17(win64)
119-
addFreeTypeIfEnabled(win64)
120-
buildTargets += win64
118+
buildTargets += createWindowsTarget(Architecture.x86)
119+
}
120+
121+
if (forWindowsArm64) {
122+
buildTargets += createWindowsTarget(Architecture.ARM)
121123
}
122124

123125
if (forLinux) {
@@ -145,6 +147,8 @@ class GenerateLibs extends DefaultTask {
145147

146148
if (forWindows)
147149
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', commonParams)
150+
if (forWindowsArm64)
151+
BuildExecutor.executeAnt(jniDir + '/build-windowsarm64.xml', commonParams)
148152
if (forLinux)
149153
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', commonParams)
150154
if (forLinuxArm64)
@@ -158,6 +162,8 @@ class GenerateLibs extends DefaultTask {
158162

159163
if (forWindows)
160164
checkLibExist("windows64/imgui-java64.dll")
165+
if (forWindowsArm64)
166+
checkLibExist("windowsarm64/imgui-java64.dll")
161167
if (forLinux)
162168
checkLibExist("linux64/libimgui-java64.so")
163169
if (forLinuxArm64)
@@ -191,6 +197,20 @@ class GenerateLibs extends DefaultTask {
191197
return linuxTarget
192198
}
193199

200+
BuildTarget createWindowsTarget(Architecture arch) {
201+
def windowsTarget = BuildTarget.newDefaultTarget(Os.Windows, Architecture.Bitness._64, arch)
202+
windowsTarget.libName = "imgui-java64.dll" // Lib for arm64 will be named the same for consistency.
203+
if (arch == Architecture.ARM) {
204+
// Windows on ARM needs an LLVM/Clang based MinGW toolchain; GCC does not ship a
205+
// Windows ARM64 target. LLVM-MinGW provides the aarch64-w64-mingw32- wrappers.
206+
windowsTarget.cCompiler = "clang"
207+
windowsTarget.cppCompiler = "clang++"
208+
}
209+
requireCpp17(windowsTarget)
210+
addFreeTypeIfEnabled(windowsTarget)
211+
return windowsTarget
212+
}
213+
194214
BuildTarget createMacTarget(Architecture arch) {
195215
def minMacOsVersion = '10.15'
196216
def macTarget = BuildTarget.newDefaultTarget(Os.MacOsX, Architecture.Bitness._64, arch)

‎imgui-app/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies {
2424
api 'org.lwjgl:lwjgl-opengl'
2525
api 'org.lwjgl:lwjgl-sdl'
2626

27-
['natives-linux', 'natives-windows', 'natives-macos', 'natives-macos-arm64'].each {
27+
['natives-linux', 'natives-windows', 'natives-windows-arm64', 'natives-macos', 'natives-macos-arm64'].each {
2828
api "org.lwjgl:lwjgl::$it"
2929
api "org.lwjgl:lwjgl-glfw::$it"
3030
api "org.lwjgl:lwjgl-opengl::$it"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- a/crude_json.cpp
2+
+++ b/crude_json.cpp
3+
@@ -6,6 +6,7 @@
4+
// CREDITS
5+
// Written by Michal Cichon
6+
# include "crude_json.h"
7+
+# include <exception>
8+
# include <iomanip>
9+
# include <limits>
10+
# include <cstdlib>

0 commit comments

Comments
 (0)