feat(build): add remote-build-display-control.sh for workstation → Mac builds

Copies display_control.m to laptop 01 via SSH, compiles universal binary
(x86_64 + arm64) on the remote Mac, pulls binary back to resources/bin/.
Defaults to 192.168.32.101; accepts optional IP override as $1.

README: restructure display_control build section — Option A (remote from
workstation, preferred) and Option B (direct on Mac).
This commit is contained in:
Scott Idem
2026-05-20 17:16:25 -04:00
parent 3da3b187ec
commit b6b902ad4a
2 changed files with 126 additions and 11 deletions

View File

@@ -0,0 +1,94 @@
#!/usr/bin/env bash
# scripts/remote-build-display-control.sh
# Build the display_control universal binary on a remote Mac via SSH,
# then pull the result back to resources/bin/display_control.
#
# Use this from the Linux workstation when you don't have a Mac locally.
# The target Mac must have Xcode Command Line Tools installed.
#
# USAGE:
# ./scripts/remote-build-display-control.sh # uses default Mac (laptop 01)
# ./scripts/remote-build-display-control.sh 192.168.32.102
#
# The default IP is laptop 01 — the designated build Mac.
# Change DEFAULT_IP below if Xcode moves to a different laptop.
#
# SSH key must already be installed on the target:
# ssh-copy-id "speaker ready"@192.168.32.101
set -eo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SRC="$SCRIPT_DIR/display_control.m"
OUT_BIN="$REPO_ROOT/resources/bin/display_control"
SSH_USER="speaker ready"
DEFAULT_IP="192.168.32.101"
IP="${1:-$DEFAULT_IP}"
REMOTE_TMP="/tmp/ae_display_control_build"
echo "═══════════════════════════════════════════════"
echo " Remote build: display_control"
echo " Build Mac: $SSH_USER @ $IP"
echo "═══════════════════════════════════════════════"
# ── Step 1: Copy source to remote ────────────────────────────────────────────
echo ""
echo "Step 1/4 — Copying source to $IP..."
ssh "$SSH_USER@$IP" "mkdir -p $REMOTE_TMP"
scp "$SRC" "$SSH_USER@$IP:$REMOTE_TMP/display_control.m"
# ── Step 2: Build universal binary on remote ──────────────────────────────────
echo ""
echo "Step 2/4 — Building on $IP..."
ssh "$SSH_USER@$IP" bash << 'ENDSSH'
set -e
REMOTE_TMP="/tmp/ae_display_control_build"
SRC="$REMOTE_TMP/display_control.m"
TMP_X86="$REMOTE_TMP/display_control_x86_64"
TMP_ARM="$REMOTE_TMP/display_control_arm64"
OUT="$REMOTE_TMP/display_control"
echo " Compiling x86_64..."
clang -arch x86_64 -framework Cocoa -framework Carbon -o "$TMP_X86" "$SRC"
echo " Compiling arm64..."
clang -arch arm64 -framework Cocoa -framework Carbon -o "$TMP_ARM" "$SRC"
echo " Linking universal binary..."
lipo -create -output "$OUT" "$TMP_X86" "$TMP_ARM"
rm "$TMP_X86" "$TMP_ARM"
chmod +x "$OUT"
echo " Archs: $(lipo -archs "$OUT")"
ENDSSH
# ── Step 3: Pull binary back ──────────────────────────────────────────────────
echo ""
echo "Step 3/4 — Pulling binary to resources/bin/..."
mkdir -p "$(dirname "$OUT_BIN")"
scp "$SSH_USER@$IP:$REMOTE_TMP/display_control" "$OUT_BIN"
chmod +x "$OUT_BIN"
# ── Step 4: Clean up remote ───────────────────────────────────────────────────
echo ""
echo "Step 4/4 — Cleaning up remote..."
ssh "$SSH_USER@$IP" "rm -rf $REMOTE_TMP"
# ── Done ──────────────────────────────────────────────────────────────────────
echo ""
echo "═══════════════════════════════════════════════"
echo " Built: $OUT_BIN"
file "$OUT_BIN"
echo ""
echo " If both archs shown above, you're good:"
echo " git add resources/bin/display_control"
echo " git commit -m \"build: update display_control binary (universal)\""
echo "═══════════════════════════════════════════════"