build(binding): add universal macOS ARM64 dylib and static FreeType compilation
- Static FreeType linking flow for all OS - Flow to build universal binaries for macOS (x86_64, aarch64) - Simplified CI workflow by removing FreeType branches from the build matrix Added 2 new scripts: 1. `buildSrc/scripts/vendor_freetype.sh` 2. `buildSrc/scripts/build.sh` The first script prepares FreeType for usage in the build process. The result of this script is used in the `GenerateLibs` task. Other ways of building with FreeType are removed. If it's impossible to build with FreeType, it is recommended to set `freetype=false`. The second script aggregates commands to build native binaries. It includes specific steps, such as creating a universal library for macOS and copying the result to the specific folder `/tmp/imgui/dst`. Script 1 can be used for local builds. Script 2 is primarily intended for use in CI.
This commit is contained in:
16 files changed
+423
-220
No files matched your search
Executable
+106
@@ -0,0 +1,106 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Setting base directory and navigating to project root..."
|
||||
BASEDIR=$(dirname "$0")
|
||||
cd "$BASEDIR"/../.. || exit 1
|
||||
echo "Navigated to $(pwd)"
|
||||
|
||||
# Check if vendor type argument is provided
|
||||
if [ -z "$1" ]; then
|
||||
echo "Vendor type is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VTYPE=$1
|
||||
echo "Vendor type set to '$VTYPE'"
|
||||
|
||||
# Make the vendor FreeType script executable and run it
|
||||
echo "Making vendor FreeType script executable and running it..."
|
||||
chmod +x buildSrc/scripts/vendor_freetype.sh
|
||||
buildSrc/scripts/vendor_freetype.sh "$VTYPE"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Vendor FreeType script failed"
|
||||
exit 1
|
||||
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
|
||||
echo "Directory /tmp/imgui/dst created successfully"
|
||||
|
||||
# Function to check if a file exists
|
||||
check_file_exists() {
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "File $1 not found!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Determine build process based on vendor type
|
||||
case "$VTYPE" in
|
||||
windows)
|
||||
echo "Running Gradle task for Windows..."
|
||||
./gradlew imgui-binding:generateLibs -Denvs=windows -Dfreetype=true
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Gradle task for Windows failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Checking if the generated DLL exists..."
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to copy DLL to /tmp/imgui/dst/imgui-java64.dll"
|
||||
exit 1
|
||||
fi
|
||||
echo "DLL copied to /tmp/imgui/dst/imgui-java64.dll successfully"
|
||||
;;
|
||||
linux)
|
||||
echo "Running Gradle task for Linux..."
|
||||
./gradlew imgui-binding:generateLibs -Denvs=linux -Dfreetype=true
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Gradle task for Linux failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Checking if the generated SO file exists..."
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to copy SO file to /tmp/imgui/dst/libimgui-java64.so"
|
||||
exit 1
|
||||
fi
|
||||
echo "SO file copied to /tmp/imgui/dst/libimgui-java64.so successfully"
|
||||
;;
|
||||
macos)
|
||||
echo "Running Gradle task for macOS and macOS ARM..."
|
||||
./gradlew imgui-binding:generateLibs -Denvs=macos,macosarm64 -Dfreetype=true
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Gradle task for macOS failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Checking if the generated DYLIB files exist..."
|
||||
check_file_exists /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib
|
||||
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
|
||||
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"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown vendor type: $VTYPE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Script completed successfully."
|
||||
Reference in new issue
Block a user