Skip to content
Open
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
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ jobs:
target:
- os: ubuntu-latest
type: linux
- os: ubuntu-24.04-arm
type: linuxarm64
- os: ubuntu-latest
type: windows
- os: ubuntu-latest
type: windowsarm64
- os: macos-latest
type: macos
runs-on: ${{ matrix.target.os }}
Expand All @@ -80,6 +84,18 @@ jobs:
if: matrix.target.type == 'windows'
run: sudo apt install mingw-w64

- name: Install Dependencies (for Windows ARM64 build)
if: matrix.target.type == 'windowsarm64'
run: |
# Use LLVM-MinGW compiler to cross-compile to Windows ARM64
# (download from the original repo, as Ubuntu doesn't provide a package for it)
LLVM_VERSION=20261104
LLVM_UBUNTU=llvm-mingw-${LLVM_VERSION}-ucrt-ubuntu-22.04-x86_64
LLVM_URL=https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_VERSION}/${LLVM_UBUNTU}.tar.xz
wget -c -O llvm-mingw.tar.xz $LLVM_URL
tar -xf llvm-mingw.tar.xz
echo "$GITHUB_WORKSPACE/$LLVM_UBUNTU/bin" >> $GITHUB_PATH

- name: Build
run: |
chmod +x buildSrc/scripts/build.sh
Expand Down
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,24 @@ This is the path CI uses. It vendors FreeType, runs `generateLibs`, and lays the
`/tmp/imgui/dst/`:

```
buildSrc/scripts/build.sh <windows|linux|macos>
buildSrc/scripts/build.sh <windows|windowsarm64|linux|linuxarm64|macos>
```

For `macos` it builds both `x86_64` and `arm64` slices and combines them into a single universal `libimgui-java64.dylib`
via `lipo`.

To use the freshly-built binary with the example:
To use the freshly-built binary with the example, for instance, for `x64` platforms:

```
cp /tmp/imgui/dst/libimgui-java64.<so|dylib|dll> bin/
./gradlew :example:run -PlibPath=$PWD/bin
cp /tmp/imgui/dst/x64/libimgui-java64.<so|dylib|dll> bin/x64/
./gradlew :example:run -Pimgui.library.path=$PWD/bin/x64
```

and for `arm64` platforms:

```
cp /tmp/imgui/dst/arm64/libimgui-java64.<so|dylib|dll> bin/arm64/
./gradlew :example:run -Pimgui.library.path=$PWD/bin/arm64
```

## Direct Gradle invocation
Expand All @@ -428,30 +435,36 @@ If you don't need FreeType or want a stock build under the project tree, call `g
- Required on PATH: Ant, Mingw-w64 (recommended via [MSYS2](https://www.msys2.org/) — install
the [mingw-w64-x86_64-toolchain](https://packages.msys2.org/group/mingw-w64-x86_64-toolchain) group).
- Build: `./gradlew imgui-binding:generateLibs -Denvs=windows -Dlocal`
- Run example: `./gradlew example:run -PlibPath="../imgui-binding/build/libsNative/windows64"`
- Run example: `./gradlew example:run -Pimgui.library.path="../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"`
- Run example: `./gradlew example:run -Pimgui.library.path="../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.)
- Install dependencies: `build-essential`, `ant`. (Package names vary by distro.)
- Build: `./gradlew imgui-binding:generateLibs -Denvs=linux -Dlocal`
- Run example: `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/linux64`
- Run example: `./gradlew example:run -Pimgui.library.path=../imgui-binding/build/libsNative/linux64`

### Linux ARM64

- Install dependencies: `build-essential`, `ant`. (Package names vary by distro.)
- Build: `./gradlew imgui-binding:generateLibs -Denvs=linuxarm64 -Dlocal`
- Run example: `./gradlew example:run -Pimgui.library.path=../imgui-binding/build/libsNative/linuxarm64`

### macOS

- Same toolchain dependencies as Linux.
- Build (universal): `./gradlew imgui-binding:generateLibs -Denvs=macos,macosarm64 -Dlocal` — produces `macosx64/` and
`macosxarm64/` outputs that the Maven Central artifact bundles together via `lipo` (see `buildSrc/scripts/build.sh`).
- Single slice: pass only `-Denvs=macos` or `-Denvs=macosarm64`.
- Run example (Intel slice): `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/macosx64`
- Run example (Intel slice): `./gradlew example:run -Pimgui.library.path=../imgui-binding/build/libsNative/macosx64`

### Flags

Expand Down
File renamed without changes.
File renamed without changes.
Binary file added bin/x64/libimgui-java64.dylib
Binary file not shown.
File renamed without changes.
62 changes: 51 additions & 11 deletions buildSrc/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ if [ $? -ne 0 ]; then
fi
echo "Vendor FreeType script completed successfully"

# Create the destination directory for imgui libraries
echo "Creating destination directory for imgui libraries..."
mkdir -p /tmp/imgui/dst
# Create the destination directories for imgui libraries
echo "Creating destination directories for imgui libraries..."
mkdir -p /tmp/imgui/dst/x64
mkdir -p /tmp/imgui/dst/arm64
echo "Directory /tmp/imgui/dst created successfully"

# Function to check if a file exists
Expand All @@ -51,12 +52,31 @@ case "$VTYPE" in
check_file_exists /tmp/imgui/libsNative/windows64/imgui-java64.dll

echo "Copying the generated DLL to the destination directory..."
cp /tmp/imgui/libsNative/windows64/imgui-java64.dll /tmp/imgui/dst/imgui-java64.dll
cp /tmp/imgui/libsNative/windows64/imgui-java64.dll /tmp/imgui/dst/x64/imgui-java64.dll
if [ $? -ne 0 ]; then
echo "Failed to copy DLL to /tmp/imgui/dst/imgui-java64.dll"
echo "Failed to copy DLL to /tmp/imgui/dst/x64/imgui-java64.dll"
exit 1
fi
echo "DLL copied to /tmp/imgui/dst/imgui-java64.dll successfully"
echo "DLL copied to /tmp/imgui/dst/x64/imgui-java64.dll successfully"
;;
windowsarm64)
echo "Running Gradle task for Windows ARM64..."
./gradlew imgui-binding:generateLibs -Denvs=windowsarm64 -Dfreetype=true
if [ $? -ne 0 ]; then
echo "Gradle task for Windows ARM64 failed"
exit 1
fi

echo "Checking if the generated DLL exists..."
check_file_exists /tmp/imgui/libsNative/windowsarm64/imgui-java64.dll

echo "Copying the generated DLL to the destination directory..."
cp /tmp/imgui/libsNative/windowsarm64/imgui-java64.dll /tmp/imgui/dst/arm64/imgui-java64.dll
if [ $? -ne 0 ]; then
echo "Failed to copy DLL to /tmp/imgui/dst/arm64/imgui-java64.dll"
exit 1
fi
echo "DLL copied to /tmp/imgui/dst/arm64/imgui-java64.dll successfully"
;;
linux)
echo "Running Gradle task for Linux..."
Expand All @@ -70,12 +90,31 @@ case "$VTYPE" in
check_file_exists /tmp/imgui/libsNative/linux64/libimgui-java64.so

echo "Copying the generated SO file to the destination directory..."
cp /tmp/imgui/libsNative/linux64/libimgui-java64.so /tmp/imgui/dst/libimgui-java64.so
cp /tmp/imgui/libsNative/linux64/libimgui-java64.so /tmp/imgui/dst/x64/libimgui-java64.so
if [ $? -ne 0 ]; then
echo "Failed to copy SO file to /tmp/imgui/dst/x64/libimgui-java64.so"
exit 1
fi
echo "SO file copied to /tmp/imgui/dst/x64/libimgui-java64.so successfully"
;;
linuxarm64)
echo "Running Gradle task for Linux ARM64..."
./gradlew imgui-binding:generateLibs -Denvs=linuxarm64 -Dfreetype=true
if [ $? -ne 0 ]; then
echo "Gradle task for Linux ARM64 failed"
exit 1
fi

echo "Checking if the generated SO file exists..."
check_file_exists /tmp/imgui/libsNative/linuxarm64/libimgui-java64.so

echo "Copying the generated SO file to the destination directory..."
cp /tmp/imgui/libsNative/linuxarm64/libimgui-java64.so /tmp/imgui/dst/arm64/libimgui-java64.so
if [ $? -ne 0 ]; then
echo "Failed to copy SO file to /tmp/imgui/dst/libimgui-java64.so"
echo "Failed to copy SO file to /tmp/imgui/dst/arm64/libimgui-java64.so"
exit 1
fi
echo "SO file copied to /tmp/imgui/dst/libimgui-java64.so successfully"
echo "SO file copied to /tmp/imgui/dst/arm64/libimgui-java64.so successfully"
;;
macos)
echo "Running Gradle task for macOS and macOS ARM..."
Expand All @@ -90,12 +129,13 @@ case "$VTYPE" in
check_file_exists /tmp/imgui/libsNative/macosxarm64/libimgui-java64.dylib

echo "Creating a universal library using lipo..."
lipo -create -output /tmp/imgui/dst/libimgui-java64.dylib /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib /tmp/imgui/libsNative/macosxarm64/libimgui-java64.dylib
lipo -create -output /tmp/imgui/dst/x64/libimgui-java64.dylib /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib /tmp/imgui/libsNative/macosxarm64/libimgui-java64.dylib
if [ $? -ne 0 ]; then
echo "Failed to create universal library with lipo"
exit 1
fi
echo "Universal library created at /tmp/imgui/dst/libimgui-java64.dylib successfully"
cp /tmp/imgui/dst/x64/libimgui-java64.dylib /tmp/imgui/dst/arm64/libimgui-java64.dylib
echo "Universal library created at /tmp/imgui/dst/**/libimgui-java64.dylib successfully"
;;
*)
echo "Unknown vendor type: $VTYPE"
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/scripts/vendor_freetype.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ case "$VTYPE" in
windows)
build_freetype "" "--host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32" "lib/libfreetype.a"
;;
windowsarm64)
build_freetype "" "--host=aarch64-w64-mingw32 --prefix=/usr/aarch64-w64-mingw32" "lib/libfreetype.a"
;;
linux)
build_freetype "-fPIC" "" "lib/libfreetype.a"
;;
linuxarm64)
build_freetype "-fPIC" "" "lib/libfreetype.a"
;;
macos)
MACOS_VERSION=10.15

Expand Down
8 changes: 4 additions & 4 deletions 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-windows-arm64', 'natives-macos', 'natives-macos-arm64'].each {
['natives-linux', 'natives-linux-arm64', '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 All @@ -37,9 +37,9 @@ dependencies {

jar {
from('../bin') {
include 'imgui-java64.dll'
include 'libimgui-java64.so'
include 'libimgui-java64.dylib'
include '**/imgui-java64.dll'
include '**/libimgui-java64.so'
include '**/libimgui-java64.dylib'
into 'io/imgui/java/native-bin/'
}

Expand Down
2 changes: 1 addition & 1 deletion imgui-binding-natives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ switch (findProperty('deployType')) {

jar {
from(fromDir) {
include "$libName" // this is fine
include "**/$libName" // this is fine
into 'io/imgui/java/native-bin/'
}
manifest {
Expand Down
Loading