build(display): universal binary — compile x86_64 + arm64 and lipo into fat binary

Compiles both arches separately then links with lipo -create.
Prevents silent failure when a binary built on Apple Silicon is deployed
to Intel venue Macs (MacBook Air 2018 fleet).
This commit is contained in:
Scott Idem
2026-05-20 17:10:56 -04:00
parent 86ea73bfbd
commit 3da3b187ec
2 changed files with 20 additions and 4 deletions

View File

@@ -363,6 +363,9 @@ xcode-select --install
# From the repo root:
./scripts/build-display-control.sh
# The script compiles x86_64 and arm64 separately then links a universal binary.
# Expected output at the end: x86_64 arm64
# Test with a second display connected:
./resources/bin/display_control status
./resources/bin/display_control extend

View File

@@ -24,13 +24,26 @@ fi
mkdir -p "$OUT_DIR"
echo "Building display_control..."
clang -framework Cocoa -framework Carbon \
-o "$OUT_BIN" "$SRC"
TMP_X86="$OUT_DIR/display_control_x86_64"
TMP_ARM="$OUT_DIR/display_control_arm64"
echo "Building display_control (x86_64)..."
clang -arch x86_64 -framework Cocoa -framework Carbon \
-o "$TMP_X86" "$SRC"
echo "Building display_control (arm64)..."
clang -arch arm64 -framework Cocoa -framework Carbon \
-o "$TMP_ARM" "$SRC"
echo "Linking universal binary..."
lipo -create -output "$OUT_BIN" "$TMP_X86" "$TMP_ARM"
rm "$TMP_X86" "$TMP_ARM"
chmod +x "$OUT_BIN"
echo "Built: $OUT_BIN"
echo ""
echo "Built universal binary: $OUT_BIN"
lipo -archs "$OUT_BIN"
echo ""
echo "Test it:"
echo " $OUT_BIN status"