Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ If you don't need FreeType or want a stock build under the project tree, call `g
- Build: `./gradlew imgui-binding:generateLibs -Denvs=windows -Dlocal`
- Run example: `./gradlew example:run -PlibPath="../imgui-binding/build/libsNative/windows64"`

### Windows ARM64

- Required on PATH: Ant, [LLVM-MinGW](https://github.com/mstorsjo/llvm-mingw) (the `aarch64-w64-mingw32-*`
wrappers).
- Build: `./gradlew imgui-binding:generateLibs -Denvs=windowsarm64 -Dlocal`
- Output: `imgui-binding/build/libsNative/windowsarm64/imgui-java64.dll`
- Run example: `./gradlew example:run -PlibPath="../imgui-binding/build/libsNative/windowsarm64"`
- The direct Gradle path builds without FreeType by default, matching the other platforms.

### Linux

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

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

Expand Down
6 changes: 6 additions & 0 deletions buildSrc/scripts/apply_vendor_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ apply_patch_idempotent() {
apply_patch_idempotent \
"$(pwd)/patches/imgui-node-editor-imgui-1.92-operator-star.patch" \
include/imgui-node-editor

# LLVM-MinGW's libc++ does not transitively include <exception>, so the
# Windows ARM64 build needs the explicit include for std::terminate().
apply_patch_idempotent \
"$(pwd)/patches/imgui-node-editor-libcxx-exception.patch" \
include/imgui-node-editor
28 changes: 24 additions & 4 deletions buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GenerateLibs extends DefaultTask {

private final String[] buildEnvs = System.getProperty('envs')?.split(',')
private final boolean forWindows = buildEnvs?.contains('windows')
private final boolean forWindowsArm64 = buildEnvs?.contains('windowsarm64')
private final boolean forLinux = buildEnvs?.contains('linux')
private final boolean forLinuxArm64 = buildEnvs?.contains('linuxarm64')
private final boolean forMac = buildEnvs?.contains('macos')
Expand Down Expand Up @@ -114,10 +115,11 @@ class GenerateLibs extends DefaultTask {
BuildTarget[] buildTargets = []

if (forWindows) {
def win64 = BuildTarget.newDefaultTarget(Os.Windows, Architecture.Bitness._64)
requireCpp17(win64)
addFreeTypeIfEnabled(win64)
buildTargets += win64
buildTargets += createWindowsTarget(Architecture.x86)
}

if (forWindowsArm64) {
buildTargets += createWindowsTarget(Architecture.ARM)
}

if (forLinux) {
Expand Down Expand Up @@ -145,6 +147,8 @@ class GenerateLibs extends DefaultTask {

if (forWindows)
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', commonParams)
if (forWindowsArm64)
BuildExecutor.executeAnt(jniDir + '/build-windowsarm64.xml', commonParams)
if (forLinux)
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', commonParams)
if (forLinuxArm64)
Expand All @@ -158,6 +162,8 @@ class GenerateLibs extends DefaultTask {

if (forWindows)
checkLibExist("windows64/imgui-java64.dll")
if (forWindowsArm64)
checkLibExist("windowsarm64/imgui-java64.dll")
if (forLinux)
checkLibExist("linux64/libimgui-java64.so")
if (forLinuxArm64)
Expand Down Expand Up @@ -191,6 +197,20 @@ class GenerateLibs extends DefaultTask {
return linuxTarget
}

BuildTarget createWindowsTarget(Architecture arch) {
def windowsTarget = BuildTarget.newDefaultTarget(Os.Windows, Architecture.Bitness._64, arch)
windowsTarget.libName = "imgui-java64.dll" // Lib for arm64 will be named the same for consistency.
if (arch == Architecture.ARM) {
// Windows on ARM needs an LLVM/Clang based MinGW toolchain; GCC does not ship a
// Windows ARM64 target. LLVM-MinGW provides the aarch64-w64-mingw32- wrappers.
windowsTarget.cCompiler = "clang"
windowsTarget.cppCompiler = "clang++"
}
requireCpp17(windowsTarget)
addFreeTypeIfEnabled(windowsTarget)
return windowsTarget
}

BuildTarget createMacTarget(Architecture arch) {
def minMacOsVersion = '10.15'
def macTarget = BuildTarget.newDefaultTarget(Os.MacOsX, Architecture.Bitness._64, arch)
Expand Down
2 changes: 1 addition & 1 deletion imgui-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
api 'org.lwjgl:lwjgl-opengl'
api 'org.lwjgl:lwjgl-sdl'

['natives-linux', 'natives-windows', 'natives-macos', 'natives-macos-arm64'].each {
['natives-linux', 'natives-windows', 'natives-windows-arm64', 'natives-macos', 'natives-macos-arm64'].each {
api "org.lwjgl:lwjgl::$it"
api "org.lwjgl:lwjgl-glfw::$it"
api "org.lwjgl:lwjgl-opengl::$it"
Expand Down
10 changes: 10 additions & 0 deletions patches/imgui-node-editor-libcxx-exception.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/crude_json.cpp
+++ b/crude_json.cpp
@@ -6,6 +6,7 @@
// CREDITS
// Written by Michal Cichon
# include "crude_json.h"
+# include <exception>
# include <iomanip>
# include <limits>
# include <cstdlib>
Loading