@@ -249,6 +249,12 @@ jobs:
249249
250250 # Add @rpath so the engine finds libs relative to itself.
251251 install_name_tool -add_rpath "$PREFIX" "$ENGINE" 2>/dev/null || true
252+ # Remove any stale Homebrew rpath entries from the build host.
253+ # The engine may pick up /opt/homebrew/Cellar/... paths from the
254+ # cmake link step; these must not leak into the bundle.
255+ while IFS= read -r rp; do
256+ install_name_tool -delete_rpath "$rp" "$ENGINE" 2>/dev/null || true
257+ done < <(otool -l "$ENGINE" | awk '/LC_RPATH/{found=1} found && /path /{print $2; found=0}' | grep '/opt/homebrew')
252258
253259 # Bundle Mesa's full lib stack (Zink + KosmicKrisp need it).
254260 MESA_PREFIX="$(brew --prefix mesa)"
@@ -303,7 +309,9 @@ jobs:
303309
304310 # Package Beyond-All-Reason game content as .sdd directory.
305311 # Exclude dev-only files that bloat the bundle.
306- GAME_SDD="$GAME_DIR/games/Beyond All Reason $GAME_VERSION"
312+ # The .sdd suffix is required for the engine's archive scanner
313+ # to recognise the directory as a Spring Data Directory.
314+ GAME_SDD="$GAME_DIR/games/Beyond All Reason $GAME_VERSION.sdd"
307315 rsync -a \
308316 --exclude='.git' \
309317 --exclude='.gitignore' \
@@ -318,7 +326,7 @@ jobs:
318326 rm -f "$GAME_SDD/modinfo.lua.bak"
319327
320328 # Package BYAR-Chobby lobby as .sdd directory.
321- LOBBY_SDD="$GAME_DIR/games/BYAR Chobby $LOBBY_VERSION"
329+ LOBBY_SDD="$GAME_DIR/games/BYAR Chobby $LOBBY_VERSION.sdd "
322330 rsync -a \
323331 --exclude='.git' \
324332 --exclude='.gitignore' \
@@ -335,6 +343,32 @@ jobs:
335343 echo " Game: Beyond All Reason $GAME_VERSION"
336344 echo " Lobby: BYAR Chobby $LOBBY_VERSION"
337345
346+ # ---- Bundle base content ----
347+ # The engine requires base content archives that ship as part
348+ # of the engine build: springcontent.sdz (fonts, base Lua),
349+ # bitmaps.sdz (UI icons), maphelper.sdz (map Lua utilities),
350+ # and cursors.sdz (cursor images). Without these, the engine
351+ # cannot load any game or menu archive because springcontent
352+ # declares a dependency on "Spring Bitmaps" which comes from
353+ # bitmaps.sdz.
354+ cp -f ../build/base/springcontent.sdz "$GAME_DIR/games/"
355+ cp -f ../build/base/spring/bitmaps.sdz "$GAME_DIR/games/"
356+ cp -f ../build/base/maphelper.sdz "$GAME_DIR/games/"
357+ cp -f ../build/base/cursors.sdz "$GAME_DIR/games/"
358+ echo " Base content: springcontent, bitmaps, maphelper, cursors"
359+
360+ # FreeSans font required by the engine's font loader.
361+ # Downloaded from GNU FreeFont and placed in the game's
362+ # fonts/ directory. The engine looks for
363+ # fonts/FreeSansBold.otf relative to the writeable data dir.
364+ FONT_DIR="$GAME_DIR/fonts"
365+ mkdir -p "$FONT_DIR"
366+ curl -sL "https://ftp.gnu.org/gnu/freefont/freefont-otf-20120503.tar.gz" | \
367+ tar xz -C "$FONT_DIR" --strip-components=1 "freefont-otf-20120503/FreeSansBold.otf"
368+ if [ ! -f "$FONT_DIR/FreeSansBold.otf" ]; then
369+ echo "::warning::Failed to download FreeSansBold.otf, game may fail to start"
370+ fi
371+
338372 # Launcher: the engine runs in isolation mode with the game
339373 # data directory inside the bundle. User data (logs, configs,
340374 # downloaded maps) goes to Library/Application Support.
@@ -358,6 +392,10 @@ jobs:
358392 # The engine needs to find its bundled Mesa + Vulkan libs.
359393 export DYLD_LIBRARY_PATH="\$RES/lib:\${DYLD_LIBRARY_PATH:-}"
360394 export DYLD_FRAMEWORK_PATH="\$RES/lib:\${DYLD_FRAMEWORK_PATH:-}"
395+ # Mesa EGL on macOS must use the surfaceless platform because
396+ # there is no X11 display server. Without this, eglInitialize
397+ # tries to connect to xcb and fails with EGL_NOT_INITIALIZED.
398+ export EGL_PLATFORM=surfaceless
361399 # Vulkan loader looks here for the KosmicKrisp / MoltenVK ICD.
362400 export VK_DRIVER_FILES="\$RES/share/vulkan/icd.d/MoltenVK_icd.json"
363401 export VK_ICD_FILENAMES="\$RES/share/vulkan/icd.d/MoltenVK_icd.json"
@@ -499,20 +537,31 @@ jobs:
499537 fi
500538 echo "All Mach-Os use @executable_path-relative paths"
501539
540+ echo "--- Engine rpath audit ---"
541+ # The engine must not carry stale /opt/homebrew rpath entries
542+ # from the build host. Only @executable_path/../lib is valid.
543+ RPATH_COUNT=$(otool -l "$ENGINE" | awk '/LC_RPATH/{found=1} found && /path /{print $2; found=0}' | grep -c '/opt/homebrew' || true)
544+ if [ "$RPATH_COUNT" -ne 0 ]; then
545+ echo "::error::$RPATH_COUNT stale /opt/homebrew rpath entries in engine binary"
546+ otool -l "$ENGINE" | awk '/LC_RPATH/{found=1} found && /path /{print $2; found=0}' | grep '/opt/homebrew'
547+ exit 1
548+ fi
549+ echo "Engine rpath clean"
550+
502551 echo "--- Game content verification ---"
503552 GAME_DIR="$APP/Contents/Resources/game"
504553 if [ ! -d "$GAME_DIR/games" ]; then
505554 echo "::error::$GAME_DIR/games does not exist"
506555 exit 1
507556 fi
508- SDD_COUNT=$(find "$GAME_DIR/games" -mindepth 1 -maxdepth 1 -type d | wc -l | tr -d ' ')
557+ SDD_COUNT=$(find "$GAME_DIR/games" -mindepth 1 -maxdepth 1 -name '*.sdd' - type d | wc -l | tr -d ' ')
509558 echo "Found $SDD_COUNT .sdd directories"
510559 if [ "$SDD_COUNT" -lt 2 ]; then
511560 echo "::error::Expected at least 2 .sdd directories (game + lobby), found $SDD_COUNT"
512561 exit 1
513562 fi
514563 # Verify each .sdd has modinfo.lua and $VERSION was replaced.
515- for sdd in "$GAME_DIR/games"/*/; do
564+ for sdd in "$GAME_DIR/games"/*.sdd /; do
516565 MODINFO="${sdd}modinfo.lua"
517566 if [ ! -f "$MODINFO" ]; then
518567 echo "::error::Missing modinfo.lua in $sdd"
@@ -526,6 +575,20 @@ jobs:
526575 VER=$(awk -F"'" '/version = /{print $2; exit}' "$MODINFO")
527576 echo " .sdd OK: $NAME $VER"
528577 done
578+ # Verify base content archives exist.
579+ for base in springcontent.sdz bitmaps.sdz maphelper.sdz cursors.sdz; do
580+ if [ ! -f "$GAME_DIR/games/$base" ]; then
581+ echo "::error::Missing base content: $base"
582+ exit 1
583+ fi
584+ echo " Base OK: $base"
585+ done
586+ # Verify FreeSans font.
587+ if [ ! -f "$GAME_DIR/fonts/FreeSansBold.otf" ]; then
588+ echo "::warning::Missing fonts/FreeSansBold.otf"
589+ else
590+ echo " Font OK: FreeSansBold.otf"
591+ fi
529592
530593 echo "--- Launcher script validation ---"
531594 if [ ! -x "$LAUNCHER" ]; then
0 commit comments