Skip to content

Commit e33a321

Browse files
committed
feat: bundle game content and lobby into .app
Checkouts Beyond-All-Reason and BYAR-Chobby from ExaDev forks, packages them as .sdd directories inside the .app bundle, and launches the engine with --isolation-dir pointing to the bundled game content and --menu to start the lobby directly. Game version strings are derived from the content commit SHAs for reproducibility. User data (configs, logs, downloaded maps) is stored in ~/Library/Application Support/Beyond All Reason/ with a symlink to the bundled games/ directory so the engine can find both bundled and user-downloaded content.
1 parent 4e4b1be commit e33a321

1 file changed

Lines changed: 91 additions & 18 deletions

File tree

.github/workflows/macos-build.yml

Lines changed: 91 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ jobs:
6161
submodules: recursive
6262
path: src
6363

64+
- name: Checkout game content (Beyond-All-Reason)
65+
uses: actions/checkout@v6
66+
with:
67+
repository: ExaDev/Beyond-All-Reason
68+
ref: macos-port
69+
path: game-data
70+
71+
- name: Checkout lobby (BYAR-Chobby)
72+
uses: actions/checkout@v6
73+
with:
74+
repository: ExaDev/BYAR-Chobby
75+
ref: macos-port
76+
path: lobby
77+
6478
- name: Show toolchain
6579
run: |
6680
sw_vers
@@ -272,28 +286,87 @@ jobs:
272286
# break the code-signed bundle seal.
273287
rsync -a --exclude='.*' ../src/doc/site/ "$APP/Contents/Resources/doc/" 2>/dev/null || true
274288
275-
# Launcher: cd into the bundle's Resources dir, then exec
276-
# the engine. Anything the engine writes (logs, savegames,
277-
# downloaded game data) lands under the user's Library/
278-
# Application Support so the .app bundle stays read-only.
279-
cat > "$APP/Contents/MacOS/$APP_NAME" <<'LAUNCHER'
289+
# ---- Bundle game content ----
290+
# The engine finds games in the "games" subdirectory of its
291+
# writeable data dir. We use --isolation-dir to point at the
292+
# bundled data so the engine finds game content inside the
293+
# .app. Game content is stored as .sdd directories (Spring
294+
# Data Directory: a directory containing modinfo.lua and all
295+
# game files). Version is derived from the short SHA for
296+
# reproducibility.
297+
GAME_DIR="$APP/Contents/Resources/game"
298+
mkdir -p "$GAME_DIR/games"
299+
300+
# Version string from game content commit.
301+
GAME_VERSION="macos-$(cd ../game-data && git rev-parse --short HEAD)"
302+
LOBBY_VERSION="macos-$(cd ../lobby && git rev-parse --short HEAD)"
303+
304+
# Package Beyond-All-Reason game content as .sdd directory.
305+
# Exclude dev-only files that bloat the bundle.
306+
GAME_SDD="$GAME_DIR/games/Beyond All Reason $GAME_VERSION"
307+
rsync -a \
308+
--exclude='.git' \
309+
--exclude='.gitignore' \
310+
--exclude='*.md' \
311+
--exclude='spec/' \
312+
--exclude='tools/' \
313+
--exclude='lux.*' \
314+
--exclude='singleplayer/' \
315+
../game-data/ "$GAME_SDD/"
316+
# Replace $VERSION placeholder in modinfo.lua.
317+
sed -i.bak "s/\\\$VERSION/$GAME_VERSION/g" "$GAME_SDD/modinfo.lua"
318+
rm -f "$GAME_SDD/modinfo.lua.bak"
319+
320+
# Package BYAR-Chobby lobby as .sdd directory.
321+
LOBBY_SDD="$GAME_DIR/games/BYAR Chobby $LOBBY_VERSION"
322+
rsync -a \
323+
--exclude='.git' \
324+
--exclude='.gitignore' \
325+
--exclude='*.md' \
326+
--exclude='autotest.sh' \
327+
--exclude='workflows/' \
328+
--exclude='dist_cfg/' \
329+
../lobby/ "$LOBBY_SDD/"
330+
# Replace $VERSION placeholder in modinfo.lua.
331+
sed -i.bak "s/\\\$VERSION/$LOBBY_VERSION/g" "$LOBBY_SDD/modinfo.lua"
332+
rm -f "$LOBBY_SDD/modinfo.lua.bak"
333+
334+
echo "Game content staged:"
335+
echo " Game: Beyond All Reason $GAME_VERSION"
336+
echo " Lobby: BYAR Chobby $LOBBY_VERSION"
337+
338+
# Launcher: the engine runs in isolation mode with the game
339+
# data directory inside the bundle. User data (logs, configs,
340+
# downloaded maps) goes to Library/Application Support.
341+
cat > "$APP/Contents/MacOS/$APP_NAME" <<LAUNCHER
280342
#!/bin/bash
281343
set -e
282-
APP_DIR="$(cd "$(dirname "$0")/.." && pwd)"
283-
RES="$APP_DIR/Resources"
284-
export SPRING_BAR_DATA="$HOME/Library/Application Support/$APP_NAME"
285-
mkdir -p "$SPRING_BAR_DATA"
344+
APP_DIR="\$(cd "\$(dirname "\$0")/.." && pwd)"
345+
RES="\$APP_DIR/Resources"
346+
GAME_DIR="\$RES/game"
347+
USER_DATA="\$HOME/Library/Application Support/$APP_NAME"
348+
mkdir -p "\$USER_DATA"
349+
# Engine data dir: user-writable area for configs/logs.
350+
# --isolation-dir restricts the data scanner to one directory,
351+
# which we set to the bundled game content. We symlink games/
352+
# into the user data area so the engine can also find any
353+
# additional maps or resources the user downloads.
354+
GAMES_LINK="\$USER_DATA/games"
355+
if [ ! -e "\$GAMES_LINK" ]; then
356+
ln -s "\$GAME_DIR/games" "\$GAMES_LINK"
357+
fi
286358
# The engine needs to find its bundled Mesa + Vulkan libs.
287-
export DYLD_LIBRARY_PATH="$RES/lib:${DYLD_LIBRARY_PATH:-}"
288-
export DYLD_FRAMEWORK_PATH="$RES/lib:${DYLD_FRAMEWORK_PATH:-}"
359+
export DYLD_LIBRARY_PATH="\$RES/lib:\${DYLD_LIBRARY_PATH:-}"
360+
export DYLD_FRAMEWORK_PATH="\$RES/lib:\${DYLD_FRAMEWORK_PATH:-}"
289361
# Vulkan loader looks here for the KosmicKrisp / MoltenVK ICD.
290-
export VK_DRIVER_FILES="$RES/share/vulkan/icd.d/MoltenVK_icd.json"
291-
export VK_ICD_FILENAMES="$RES/share/vulkan/icd.d/MoltenVK_icd.json"
292-
export VULKAN_SDK="$RES"
293-
# PR #2991 environment knobs (all default to no-op upstream;
294-
# listed here so the user can override if needed).
295-
cd "$RES"
296-
exec "$RES/bin/spring" "$@"
362+
export VK_DRIVER_FILES="\$RES/share/vulkan/icd.d/MoltenVK_icd.json"
363+
export VK_ICD_FILENAMES="\$RES/share/vulkan/icd.d/MoltenVK_icd.json"
364+
export VULKAN_SDK="\$RES"
365+
cd "\$RES"
366+
exec "\$RES/bin/spring" \\
367+
--isolation-dir "\$GAME_DIR" \\
368+
--menu "BYAR Chobby $LOBBY_VERSION" \\
369+
"\$@"
297370
LAUNCHER
298371
chmod +x "$APP/Contents/MacOS/$APP_NAME"
299372

0 commit comments

Comments
 (0)