build: macOS universal binary (arm64+x86_64) with deployment target 11.0
- Set CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_ARCHITECTURES before project() so they propagate to all FetchContent dependencies (SDL3, etc.) - build.sh: native mac release builds universal binary, detects and rebuilds single-arch libsodium, verifies with lipo, exports MACOSX_DEPLOYMENT_TARGET; dev build uses correct build/mac directory - fetch-libsodium.sh: build arm64 and x86_64 separately then merge with lipo on native macOS; fix sha256sum unavailable on macOS (use shasum)
This commit is contained in:
41
build.sh
41
build.sh
@@ -197,7 +197,14 @@ bundle_linux_daemon() {
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
build_dev() {
|
||||
header "Dev Build ($(uname -s) / $BUILD_TYPE)"
|
||||
local bd="$SCRIPT_DIR/build/linux"
|
||||
|
||||
# Use platform-appropriate build directory
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
local bd="$SCRIPT_DIR/build/mac"
|
||||
export MACOSX_DEPLOYMENT_TARGET="11.0"
|
||||
else
|
||||
local bd="$SCRIPT_DIR/build/linux"
|
||||
fi
|
||||
|
||||
if $CLEAN; then
|
||||
info "Cleaning $bd ..."; rm -rf "$bd"
|
||||
@@ -732,7 +739,9 @@ build_release_mac() {
|
||||
fi
|
||||
info "macOS cross-compiler: $OSXCROSS_CXX (arch: $MAC_ARCH)"
|
||||
else
|
||||
MAC_ARCH=$(uname -m)
|
||||
# Native macOS: build universal binary (arm64 + x86_64)
|
||||
MAC_ARCH="universal"
|
||||
export MACOSX_DEPLOYMENT_TARGET="11.0"
|
||||
fi
|
||||
|
||||
header "Release: macOS ($MAC_ARCH$(${IS_CROSS} && echo ' — cross-compile'))"
|
||||
@@ -811,12 +820,31 @@ TOOLCHAIN
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
${COMPILER_RT:+-DOSXCROSS_COMPILER_RT="$COMPILER_RT"}
|
||||
else
|
||||
info "Configuring (native) ..."
|
||||
# Build libsodium as universal if needed
|
||||
local need_sodium=false
|
||||
if [[ ! -f "$SCRIPT_DIR/libs/libsodium/lib/libsodium.a" ]] && \
|
||||
[[ ! -f "$SCRIPT_DIR/libs/libsodium-mac/lib/libsodium.a" ]]; then
|
||||
need_sodium=true
|
||||
elif [[ -f "$SCRIPT_DIR/libs/libsodium/lib/libsodium.a" ]]; then
|
||||
# Rebuild if existing lib is not universal (single-arch won't link)
|
||||
if ! lipo -info "$SCRIPT_DIR/libs/libsodium/lib/libsodium.a" 2>/dev/null | grep -q "arm64.*x86_64\|x86_64.*arm64"; then
|
||||
info "Existing libsodium is not universal — rebuilding ..."
|
||||
rm -rf "$SCRIPT_DIR/libs/libsodium"
|
||||
need_sodium=true
|
||||
fi
|
||||
fi
|
||||
if $need_sodium; then
|
||||
info "Building libsodium (universal) ..."
|
||||
"$SCRIPT_DIR/scripts/fetch-libsodium.sh"
|
||||
fi
|
||||
|
||||
info "Configuring (native universal arm64+x86_64) ..."
|
||||
cmake "$SCRIPT_DIR" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \
|
||||
-DDRAGONX_USE_SYSTEM_SDL3=OFF \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
|
||||
fi
|
||||
|
||||
info "Building with $JOBS jobs ..."
|
||||
@@ -836,6 +864,11 @@ TOOLCHAIN
|
||||
else
|
||||
info "Stripping ..."
|
||||
strip bin/ObsidianDragon
|
||||
# Verify universal binary
|
||||
if command -v lipo &>/dev/null; then
|
||||
info "Architecture info:"
|
||||
lipo -info bin/ObsidianDragon
|
||||
fi
|
||||
fi
|
||||
info "Binary: $(du -h bin/ObsidianDragon | cut -f1)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user