build(binding): macOS ARM64 native binaries (#223)
Co-authored-by: @Tom-Ski @zly2006
This commit is contained in:
1 parent
3d75eb3da0
commit
be4734090e
9 files changed
+83
-41
No files matched your search
+28
-20
@@ -30,27 +30,25 @@ jobs:
|
|||||||
imgui-lwjgl3/build/libs/*.jar
|
imgui-lwjgl3/build/libs/*.jar
|
||||||
|
|
||||||
build-natives:
|
build-natives:
|
||||||
name: Build Native (${{ matrix.type }}${{ matrix.freetype && ', freetype' || '' }})
|
name: Build Native (${{ matrix.target.type }}${{ matrix.freetype && ', freetype' || '' }})
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest, macos-latest ]
|
|
||||||
type: [ windows, linux, macos ]
|
|
||||||
freetype: [ true, false ]
|
freetype: [ true, false ]
|
||||||
include:
|
target:
|
||||||
- type: windows
|
|
||||||
expected: /tmp/imgui/libsNative/windows64/imgui-java64.dll
|
|
||||||
- type: linux
|
|
||||||
expected: /tmp/imgui/libsNative/linux64/libimgui-java64.so
|
|
||||||
- type: macos
|
|
||||||
expected: /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib
|
|
||||||
exclude:
|
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
type: macos
|
|
||||||
- os: macos-latest
|
|
||||||
type: windows
|
type: windows
|
||||||
- os: macos-latest
|
expected: /tmp/imgui/libsNative/windows64/imgui-java64.dll
|
||||||
|
- os: ubuntu-latest
|
||||||
type: linux
|
type: linux
|
||||||
runs-on: ${{ matrix.os }}
|
expected: /tmp/imgui/libsNative/linux64/libimgui-java64.so
|
||||||
|
- os: macos-latest
|
||||||
|
type: macos
|
||||||
|
expected: /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib
|
||||||
|
- os: macos-latest
|
||||||
|
type: macosarm64
|
||||||
|
expected: /tmp/imgui/libsNative/macosxarm64/libimgui-javaarm64.dylib
|
||||||
|
runs-on: ${{ matrix.target.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository and Submodules
|
- name: Checkout Repository and Submodules
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -69,15 +67,15 @@ jobs:
|
|||||||
run: ant -version
|
run: ant -version
|
||||||
|
|
||||||
- name: Install MinGW-w64/GCC/G++ (Linux & Windows)
|
- name: Install MinGW-w64/GCC/G++ (Linux & Windows)
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.target.os == 'ubuntu-latest'
|
||||||
run: sudo apt install mingw-w64
|
run: sudo apt install mingw-w64
|
||||||
|
|
||||||
- name: FreeType - Install (Linux)
|
- name: FreeType - Install (Linux)
|
||||||
if: matrix.os == 'ubuntu-latest' && matrix.type == 'linux' && matrix.freetype == true
|
if: matrix.target.os == 'ubuntu-latest' && matrix.target.type == 'linux' && matrix.freetype == true
|
||||||
run: sudo apt install libfreetype6-dev
|
run: sudo apt install libfreetype6-dev
|
||||||
|
|
||||||
- name: FreeType - Install (Windows)
|
- name: FreeType - Install (Windows)
|
||||||
if: matrix.os == 'ubuntu-latest' && matrix.type == 'windows' && matrix.freetype == true
|
if: matrix.target.os == 'ubuntu-latest' && matrix.target.type == 'windows' && matrix.freetype == true
|
||||||
run: |
|
run: |
|
||||||
sudo mkdir /freetype
|
sudo mkdir /freetype
|
||||||
sudo tar -xzf ./vendor/freetype-2.12.1.tar.gz -C /freetype --strip-components=1
|
sudo tar -xzf ./vendor/freetype-2.12.1.tar.gz -C /freetype --strip-components=1
|
||||||
@@ -86,15 +84,25 @@ jobs:
|
|||||||
sudo make
|
sudo make
|
||||||
sudo make install
|
sudo make install
|
||||||
|
|
||||||
|
- name: FreeType - Install (MacOS)
|
||||||
|
if: matrix.target.os == 'macos-latest' && matrix.freetype == true
|
||||||
|
run: |
|
||||||
|
sudo mkdir /opt/freetype
|
||||||
|
sudo tar -xzf ./vendor/freetype-2.12.1.tar.gz -C /opt/freetype --strip-components=1
|
||||||
|
cd /opt/freetype
|
||||||
|
sudo ./configure CFLAGS="-arch arm64 -arch x86_64" --with-zlib=no --with-bzip2=no --with-png=no --with-harfbuzz=no --with-brotli=no
|
||||||
|
sudo make
|
||||||
|
sudo make install
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew imgui-binding:generateLibs -Denvs=${{ matrix.type }} -Dfreetype=${{ matrix.freetype }}
|
run: ./gradlew imgui-binding:generateLibs -Denvs=${{ matrix.target.type }} -Dfreetype=${{ matrix.freetype }}
|
||||||
|
|
||||||
- name: Upload Artifacts
|
- name: Upload Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.freetype && 'native-libraries-with-freetype' || 'native-libraries' }}
|
name: ${{ matrix.freetype && 'native-libraries-with-freetype' || 'native-libraries' }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
path: ${{ matrix.expected }}
|
path: ${{ matrix.target.expected }}
|
||||||
|
|
||||||
update-bin:
|
update-bin:
|
||||||
name: Update Binaries
|
name: Update Binaries
|
||||||
|
|||||||
@@ -171,11 +171,12 @@ You can refer to `imgui-app` module to see how things are done there.
|
|||||||
|
|
||||||
For simplicity, example of dependencies for Gradle / Maven only shows how to add natives for Windows. Feel free to add other platforms.
|
For simplicity, example of dependencies for Gradle / Maven only shows how to add natives for Windows. Feel free to add other platforms.
|
||||||
|
|
||||||
| Native Binaries | System |
|
| Native Binaries | System |
|
||||||
|----------------------------|---------|
|
|--------------------------------|-------------|
|
||||||
| imgui-java-natives-windows | Windows |
|
| imgui-java-natives-windows | Windows |
|
||||||
| imgui-java-natives-linux | Linux |
|
| imgui-java-natives-linux | Linux |
|
||||||
| imgui-java-natives-macos | macOS |
|
| 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.
|
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.
|
||||||
|
|
||||||
@@ -298,14 +299,15 @@ Both `imgui.library.path` and `java.library.path` are equal with the difference,
|
|||||||
|
|
||||||
If using Java 9 modules, ImGui Java has Automatic Module Names:
|
If using Java 9 modules, ImGui Java has Automatic Module Names:
|
||||||
|
|
||||||
| Package | Module |
|
| Package | Module |
|
||||||
|----------------------------|-----------------------|
|
|--------------------------------|---------------------------|
|
||||||
| imgui-java-app | imgui.app |
|
| imgui-java-app | imgui.app |
|
||||||
| imgui-java-binding | imgui.binding |
|
| imgui-java-binding | imgui.binding |
|
||||||
| imgui-java-lwjgl3 | imgui.lwjgl3 |
|
| imgui-java-lwjgl3 | imgui.lwjgl3 |
|
||||||
| imgui-java-natives-windows | imgui.natives.windows |
|
| imgui-java-natives-windows | imgui.natives.windows |
|
||||||
| imgui-java-natives-linux | imgui.natives.linux |
|
| imgui-java-natives-linux | imgui.natives.linux |
|
||||||
| imgui-java-natives-macos | imgui.natives.macos |
|
| imgui-java-natives-macos | imgui.natives.macos |
|
||||||
|
| imgui-java-natives-macos-arm64 | imgui.natives.macos-arm64 |
|
||||||
|
|
||||||
## Extensions
|
## Extensions
|
||||||
|
|
||||||
@@ -382,11 +384,12 @@ Use the same native libraries as you would, but with `-ft` suffix in the end.
|
|||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
| Native Binaries With FreeType | System |
|
| Native Binaries With FreeType | System |
|
||||||
|-------------------------------|---------|
|
|-----------------------------------|-------------|
|
||||||
| imgui-java-natives-windows-ft | Windows |
|
| imgui-java-natives-windows-ft | Windows |
|
||||||
| imgui-java-natives-linux-ft | Linux |
|
| imgui-java-natives-linux-ft | Linux |
|
||||||
| imgui-java-natives-macos-ft | macOS |
|
| 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'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.
|
||||||
|
|
||||||
@@ -427,8 +430,14 @@ Ensure you've downloaded git submodules. That could be achieved:
|
|||||||
- Check dependencies from "Linux" section and make sure you have them installed.
|
- Check dependencies from "Linux" section and make sure you have them installed.
|
||||||
- Build with: `./gradlew imgui-binding:generateLibs -Denvs=macos -Dlocal`
|
- Build with: `./gradlew imgui-binding:generateLibs -Denvs=macos -Dlocal`
|
||||||
- Run with: `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/macosx64`
|
- Run with: `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/macosx64`
|
||||||
|
|
||||||
|
### macOS-arm64
|
||||||
|
|
||||||
In `envs` parameter next values could be used `windows`, `linux` or `macos`.<br>
|
- 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`.<br>
|
||||||
`-Dlocal` is optional and means that natives will be built under the `./imgui-binding/build/` folder. Otherwise `/tmp/imgui` folder will be used.
|
`-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.
|
On Windows always use local build.
|
||||||
|
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -24,3 +24,7 @@ echo '>> Natives: [macOS, freetype]'
|
|||||||
./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macos -Pfreetype=true
|
./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macos -Pfreetype=true
|
||||||
echo '>> Natives: [macOS]'
|
echo '>> Natives: [macOS]'
|
||||||
./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macos -Pfreetype=false
|
./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macos -Pfreetype=false
|
||||||
|
echo '>> Natives: [macOS-arm64, freetype]'
|
||||||
|
./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macosarm64 -Pfreetype=true
|
||||||
|
echo '>> Natives: [macOS-arm64]'
|
||||||
|
./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macosarm64 -Pfreetype=false
|
||||||
@@ -19,6 +19,7 @@ class GenerateLibs extends DefaultTask {
|
|||||||
private final boolean forWindows = buildEnvs?.contains('windows')
|
private final boolean forWindows = buildEnvs?.contains('windows')
|
||||||
private final boolean forLinux = buildEnvs?.contains('linux')
|
private final boolean forLinux = buildEnvs?.contains('linux')
|
||||||
private final boolean forMac = buildEnvs?.contains('macos')
|
private final boolean forMac = buildEnvs?.contains('macos')
|
||||||
|
private final boolean forMacArm64 = buildEnvs?.contains('macosarm64')
|
||||||
|
|
||||||
private final boolean isLocal = System.properties.containsKey('local')
|
private final boolean isLocal = System.properties.containsKey('local')
|
||||||
private final boolean withFreeType = Boolean.valueOf(System.properties.getProperty('freetype', 'false'))
|
private final boolean withFreeType = Boolean.valueOf(System.properties.getProperty('freetype', 'false'))
|
||||||
@@ -105,6 +106,16 @@ class GenerateLibs extends DefaultTask {
|
|||||||
buildTargets += mac64
|
buildTargets += mac64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (forMacArm64) {
|
||||||
|
def minMacOsVersion = '10.15'
|
||||||
|
def macArm64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true, true)
|
||||||
|
macArm64.cppFlags += ' -std=c++14'
|
||||||
|
macArm64.cppFlags = macArm64.cppFlags.replace('10.7', minMacOsVersion)
|
||||||
|
macArm64.linkerFlags = macArm64.linkerFlags.replace('10.7', minMacOsVersion)
|
||||||
|
addFreeTypeIfEnabled(macArm64)
|
||||||
|
buildTargets += macArm64
|
||||||
|
}
|
||||||
|
|
||||||
new AntScriptGenerator().generate(buildConfig, buildTargets)
|
new AntScriptGenerator().generate(buildConfig, buildTargets)
|
||||||
|
|
||||||
// Generate native libraries
|
// Generate native libraries
|
||||||
@@ -118,6 +129,8 @@ class GenerateLibs extends DefaultTask {
|
|||||||
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', commonParams)
|
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', commonParams)
|
||||||
if (forMac)
|
if (forMac)
|
||||||
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', commonParams)
|
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', commonParams)
|
||||||
|
if (forMacArm64)
|
||||||
|
BuildExecutor.executeAnt(jniDir + '/build-macosxarm64.xml', commonParams)
|
||||||
|
|
||||||
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
|
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ dependencies {
|
|||||||
api 'org.lwjgl:lwjgl-glfw'
|
api 'org.lwjgl:lwjgl-glfw'
|
||||||
api 'org.lwjgl:lwjgl-opengl'
|
api 'org.lwjgl:lwjgl-opengl'
|
||||||
|
|
||||||
['natives-linux', 'natives-windows', 'natives-macos'].each {
|
['natives-linux', 'natives-windows', 'natives-macos', 'natives-macos-arm64'].each {
|
||||||
api "org.lwjgl:lwjgl::$it"
|
api "org.lwjgl:lwjgl::$it"
|
||||||
api "org.lwjgl:lwjgl-glfw::$it"
|
api "org.lwjgl:lwjgl-glfw::$it"
|
||||||
api "org.lwjgl:lwjgl-opengl::$it"
|
api "org.lwjgl:lwjgl-opengl::$it"
|
||||||
@@ -33,6 +33,7 @@ jar {
|
|||||||
from('../bin') {
|
from('../bin') {
|
||||||
include 'libimgui-java64.so'
|
include 'libimgui-java64.so'
|
||||||
include 'libimgui-java64.dylib'
|
include 'libimgui-java64.dylib'
|
||||||
|
include 'libimgui-javaarm64.dylib'
|
||||||
into 'io/imgui/java/native-bin/'
|
into 'io/imgui/java/native-bin/'
|
||||||
}
|
}
|
||||||
from('../bin/freetype') {
|
from('../bin/freetype') {
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ switch (findProperty('deployType')) {
|
|||||||
moduleName = 'imgui.natives.macos'
|
moduleName = 'imgui.natives.macos'
|
||||||
libName = 'libimgui-java64.dylib'
|
libName = 'libimgui-java64.dylib'
|
||||||
break
|
break
|
||||||
|
case 'macosarm64':
|
||||||
|
packageName = 'imgui-java-natives-macos-arm64'
|
||||||
|
packageDesc = 'Native binaries for imgui-java binding for MacOS arm64'
|
||||||
|
moduleName = 'imgui.natives.macos-arm64'
|
||||||
|
libName = 'libimgui-javaarm64.dylib'
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findProperty('freetype') == 'true') {
|
if (findProperty('freetype') == 'true') {
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ import java.util.Properties;
|
|||||||
public class ImGui {
|
public class ImGui {
|
||||||
private static final String LIB_PATH_PROP = "imgui.library.path";
|
private static final String LIB_PATH_PROP = "imgui.library.path";
|
||||||
private static final String LIB_NAME_PROP = "imgui.library.name";
|
private static final String LIB_NAME_PROP = "imgui.library.name";
|
||||||
private static final String LIB_NAME_DEFAULT = System.getProperty("os.arch").contains("64") ? "imgui-java64" : "imgui-java";
|
private static final boolean isARM = System.getProperty("os.arch").equals("arm") || System.getProperty("os.arch").startsWith("aarch64");
|
||||||
|
private static final String LIB_NAME_DEFAULT = "imgui-java" + (isARM ? "arm" : "") + "64";
|
||||||
private static final String LIB_TMP_DIR_PREFIX = "imgui-java-natives";
|
private static final String LIB_TMP_DIR_PREFIX = "imgui-java-natives";
|
||||||
|
|
||||||
private static final ImGuiContext IMGUI_CONTEXT;
|
private static final ImGuiContext IMGUI_CONTEXT;
|
||||||
|
|||||||
Reference in new issue
Block a user