diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c418734e..7f9ce2e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,8 +85,9 @@ jobs: name: native-library-${{ matrix.target.type }} path: /tmp/imgui/dst/ - collect-natives: - name: Collect Natives + # This required to pack all native libraries into single archive + archive-natives: + name: Archive Natives runs-on: ubuntu-latest needs: build-natives steps: @@ -100,7 +101,7 @@ jobs: name: Update Binaries if: github.ref == 'refs/heads/main' && !github.event.repository.fork # runs only on the main branch and not forks (sometimes people do PRs from the main branch) runs-on: ubuntu-latest - needs: collect-natives + needs: archive-natives steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -138,7 +139,7 @@ jobs: name: Release if: startsWith(github.ref, 'refs/tags/v') # if tag starts with "v" runs-on: ubuntu-latest - needs: [ build-java, collect-natives ] + needs: [ build-java, archive-natives ] steps: - name: Checkout Repository uses: actions/checkout@v4 diff --git a/README.md b/README.md index a4080d8e..c8332d41 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,10 @@ Gradle and Maven dependencies could be used for this purpose as well. Take a note, that integration itself is a very flexible process. It could be done in one way or another. If you just need a framework for your GUI - use [Application](#application) module. Otherwise, if you need more control, the best way is not just to repeat steps, but to understand what each step does. +### For macOS M-chip users + +The macOS version of the binding is compiled as a universal binary. This means you can use it on both x86_64 and aarch64 platforms without any additional actions. + ## Application If you don't care about OpenGL and other low-level stuff, then you can use application layer from `imgui-app` module. @@ -176,7 +180,6 @@ For simplicity, example of dependencies for Gradle / Maven only shows how to add | imgui-java-natives-windows | Windows | | imgui-java-natives-linux | Linux | | imgui-java-natives-macos | macOS | -| imgui-java-natives-macos-arm64 | macOS-arm64 | Take a note, that you also need to add dependencies to [LWJGL](https://www.lwjgl.org/) library. Examples below shows how to do it as well. @@ -307,7 +310,6 @@ If using Java 9 modules, ImGui Java has Automatic Module Names: | imgui-java-natives-windows | imgui.natives.windows | | imgui-java-natives-linux | imgui.natives.linux | | imgui-java-natives-macos | imgui.natives.macos | -| imgui-java-natives-macos-arm64 | imgui.natives.macos-arm64 | ## Extensions @@ -331,67 +333,14 @@ See examples in the `example` module for more information about how to use them. ## Freetype -By default, Dear ImGui uses stb-truetype to render fonts. Yet there is an option to use FreeType font renderer. -Go to the [imgui_freetype](https://github.com/ocornut/imgui/tree/256594575d95d56dda616c544c509740e74906b4/misc/freetype) to read about the difference. -Binding has this option too. Freetype especially useful when you use custom font with small (~<16px) size. -If you use the default font or a large font, stb will be fine for you. - -There are two types of precompiled binaries: 1. with stb (the default one) 2. with freetype. -You can decide by yourself, which kind of libraries for any system you want to use. - -Take a note, that for Linux and macOS users using of freetype will add a dependency to the `libfreetype` itself. -This is not the case for Windows users, since `dll` binaries are compiled fully statically and already include freetype in themselves. +By default, Dear ImGui uses stb-truetype to render fonts. However, there is an option to use the FreeType font renderer. +To learn about the differences, visit the [imgui_freetype](https://github.com/ocornut/imgui/tree/256594575d95d56dda616c544c509740e74906b4/misc/freetype) page. -**For fully portable application** use default binaries.
-You can still use freetype binaries for Windows builds without worry though. +This binding also supports the FreeType option. +FreeType is statically pre-compiled into the library, meaning it is **enabled by default** and there is no option to disable it. +Therefore, you can freely use `ImGuiFreeTypeBuilderFlags` in your font configuration. -**For better fonts** use freetype binaries.
-Don't forget to make clear for your Linux/Mac users, that they will need to install freetype on their systems as well. - -### Dependencies - -![Maven Central](https://img.shields.io/maven-central/v/io.github.spair/imgui-java-binding?color=green&label=version&style=flat-square) - -Use the same native libraries as you would, but with `-ft` suffix in the end. - -
- Modified Gradle Example - - ``` - repositories { - mavenCentral() - } - - ext { - lwjglVersion = '3.3.3' - imguiVersion = "${version}" - } - - dependencies { - implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion") - - ['', '-opengl', '-glfw'].each { - implementation "org.lwjgl:lwjgl$it:$lwjglVersion" - implementation "org.lwjgl:lwjgl$it::natives-windows" - } - - implementation "io.github.spair:imgui-java-binding:$imguiVersion" - implementation "io.github.spair:imgui-java-lwjgl3:$imguiVersion" - - // This is the main difference - implementation "io.github.spair:imgui-java-natives-windows-ft:$imguiVersion" - } - ``` -
- -| Native Binaries With FreeType | System | -|-----------------------------------|-------------| -| imgui-java-natives-windows-ft | Windows | -| imgui-java-natives-linux-ft | Linux | -| imgui-java-natives-macos-ft | macOS | -| imgui-java-natives-macos-arm64-ft | macOS-arm64 | - -If you're using raw dll/so files, go to the [release page](https://github.com/SpaiR/imgui-java/releases/latest) and use libraries from the `native-libraries-with-freetype.zip` archive. +If you prefer not to use the FreeType font renderer, you will need to build your own binaries and use them instead. # Binding Notice @@ -408,7 +357,7 @@ Read [javadoc](https://javadoc.io/doc/io.github.spair/imgui-java-binding) and so Ensure you've downloaded git submodules. That could be achieved: - When cloning the repository: `git clone --recurse-submodules https://github.com/SpaiR/imgui-java.git` -- When the repository cloned: `git submodule init` + `git submodule update` +- When the repository cloned: `git submodule init` and `git submodule update` ### Windows @@ -418,6 +367,7 @@ Ensure you've downloaded git submodules. That could be achieved: * Mingw-w64 (recommended way: use [MSYS2](https://www.msys2.org/) and install [mingw-w64-x86_64-toolchain](https://packages.msys2.org/group/mingw-w64-x86_64-toolchain) group) - Build with: `./gradlew imgui-binding:generateLibs -Denvs=windows -Dlocal` - Run with: `./gradlew example:run -PlibPath="../imgui-binding/build/libsNative/windows64"` + - Always use `-Dlocal` flag. ### Linux @@ -431,15 +381,20 @@ Ensure you've downloaded git submodules. That could be achieved: - Build with: `./gradlew imgui-binding:generateLibs -Denvs=macos -Dlocal` - Run with: `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/macosx64` -### macOS-arm64 +### macOS (arm64) - Check dependencies from "Linux" section and make sure you have them installed. - Build with: `./gradlew imgui-binding:generateLibs -Denvs=macosarm64 -Dlocal` - Run with: `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/macosxarm64` -In `envs` parameter next values could be used `windows`, `linux` or `macos` or `macosarm64`.
+In `envs` parameter next values could be used `windows`, `linux` or `macos` or `macosarm64`. + `-Dlocal` is optional and means that natives will be built under the `./imgui-binding/build/` folder. Otherwise `/tmp/imgui` folder will be used. -On Windows always use local build. + +## Freetype + +To build a version of the libraries with FreeType, you need to run the `buildSrc/scripts/vendor_freetype.sh` script first. +This script configures the FreeType library to be statically compiled into your project. # License diff --git a/bin/README.md b/bin/README.md index 4038f325..5811c4f7 100644 --- a/bin/README.md +++ b/bin/README.md @@ -1,10 +1,25 @@ -Folder contains libraries used by the binding and `binding.sha1` sum of the `imgui-binding/src/main` directory libraries has been built upon. +### Overview -Provide `imgui.library.path` (or `java.library.path`) VM option to the folder with one of those file (ex: `-Dimgui.library.path=./folder/path`). -In the same way you can use 'java.library.path' option instead. +The folder contains libraries used by the binding and the `binding.sha1` checksum for the `imgui-binding/src/main` directory that the libraries are built upon. These libraries are utilized during the release process. -By default, binding expects `imgui-java64` file name. -You can change that by using `imgui.library.name` VM option (ex: `-Dimgui.library.name=custom-lib-name.dll`). +### Specifying the Library Path + +To specify the folder containing these files, provide the `imgui.library.path` (or `java.library.path`) VM option. For example: +``` +-Dimgui.library.path=./folder/path +``` +You can also use the `java.library.path` option in the same manner. + +### Changing the Library Name + +By default, the binding expects the file name `imgui-java64`. You can change this by using the `imgui.library.name` VM option. For example: +``` +-Dimgui.library.name=custom-lib-name.dll +``` + +### Expected Library File Names + +The expected library file names for different operating systems are: | OS | Library | |---------|-----------------------| @@ -12,6 +27,11 @@ You can change that by using `imgui.library.name` VM option (ex: `-Dimgui.librar | Linux | libimgui-java64.so | | macOS | libimgui-java64.dylib | -Freetype directory contains same libraries, but with Freetype support. +### Additional Information + +- All libraries include statically compiled **FreeType**. +- The macOS version is a universal library and support x86_64 and arm64 architectures. + +### Continuous Integration -Hash sum in the `binding.sha1` file is used in CI to see, if there is a need to update native binaries. +The hash sum in the `binding.sha1` file is used in continuous integration (CI) to determine if there is a need to update the native binaries. diff --git a/bin/freetype/imgui-java64.dll b/bin/freetype/imgui-java64.dll deleted file mode 100644 index a8a3f46d..00000000 Binary files a/bin/freetype/imgui-java64.dll and /dev/null differ diff --git a/bin/freetype/libimgui-java64.dylib b/bin/freetype/libimgui-java64.dylib deleted file mode 100644 index c72a40a6..00000000 Binary files a/bin/freetype/libimgui-java64.dylib and /dev/null differ diff --git a/bin/freetype/libimgui-java64.so b/bin/freetype/libimgui-java64.so deleted file mode 100644 index 5a1cb1e9..00000000 Binary files a/bin/freetype/libimgui-java64.so and /dev/null differ diff --git a/bin/freetype/libimgui-javaarm64.dylib b/bin/freetype/libimgui-javaarm64.dylib deleted file mode 100644 index 1c726d4b..00000000 Binary files a/bin/freetype/libimgui-javaarm64.dylib and /dev/null differ diff --git a/bin/libimgui-javaarm64.dylib b/bin/libimgui-javaarm64.dylib deleted file mode 100644 index 72054932..00000000 Binary files a/bin/libimgui-javaarm64.dylib and /dev/null differ diff --git a/imgui-app/build.gradle b/imgui-app/build.gradle index 0e630b74..0e2368da 100644 --- a/imgui-app/build.gradle +++ b/imgui-app/build.gradle @@ -31,13 +31,9 @@ dependencies { jar { from('../bin') { + include 'imgui-java64.dll' include 'libimgui-java64.so' include 'libimgui-java64.dylib' - include 'libimgui-javaarm64.dylib' - into 'io/imgui/java/native-bin/' - } - from('../bin/freetype') { - include 'imgui-java64.dll' into 'io/imgui/java/native-bin/' } manifest { diff --git a/imgui-binding-natives/build.gradle b/imgui-binding-natives/build.gradle index 45a9fc34..27c79d19 100644 --- a/imgui-binding-natives/build.gradle +++ b/imgui-binding-natives/build.gradle @@ -31,7 +31,7 @@ switch (findProperty('deployType')) { break case 'macos': packageName = 'imgui-java-natives-macos' - packageDesc = 'Native binaries for imgui-java binding for MacOS' + packageDesc = 'Native binaries for imgui-java binding for macOS' moduleName = 'imgui.natives.macos' libName = 'libimgui-java64.dylib' break