mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-21 05:00:43 +02:00
refactor(build): extract shared pack_love.sh helper
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+1
-26
@@ -60,34 +60,9 @@ mkdir -p "$CACHE" "$WORK" "$DIST/mac" "$DIST/win" "$DIST/linux"
|
||||
# launcher's Edit button on a save row opens it in-process (main.lua), and
|
||||
# `--editor` / POKEPORT_EDITOR=1 opens it standalone. It is required through
|
||||
# love.filesystem's require path, so it has to live inside the archive.
|
||||
say "packing game.love"
|
||||
LOVE_FILE="$WORK/game.love"
|
||||
rm -f "$LOVE_FILE"
|
||||
(cd "$ROOT" && zip -q -9 -r "$LOVE_FILE" \
|
||||
main.lua conf.lua src data assets tools/save-editor \
|
||||
tools/rom_manifest.json tools/rom_manifest_blue.json \
|
||||
tools/rom_manifest_yellow.json \
|
||||
-x '*.DS_Store' 'data/generated/*' 'assets/generated/*')
|
||||
# Materialize the listing once. Piping unzip→grep -q under `set -o pipefail`
|
||||
# SIGPIPEs unzip when grep exits early on a match and aborts the build.
|
||||
LOVE_LIST="$WORK/love-listing.txt"
|
||||
unzip -Z1 "$LOVE_FILE" > "$LOVE_LIST"
|
||||
if grep -Eq '^(data|assets)/generated/[^/]+|^(data|assets)/generated/.+/' "$LOVE_LIST"; then
|
||||
fail "game.love unexpectedly contains generated ROM data"
|
||||
fi
|
||||
# The editor is only reachable if its entry point and both module directories
|
||||
# made it in, and every version's import manifest has to ship or that game's
|
||||
# ROM import fails in the built app (dev reads them off the source tree, so
|
||||
# the miss only ever shows up in a build -- the Yellow manifest shipped this
|
||||
# way once).
|
||||
for required in tools/save-editor/App.lua tools/save-editor/Kit.lua \
|
||||
tools/save-editor/panels/Party.lua \
|
||||
tools/rom_manifest.json tools/rom_manifest_blue.json \
|
||||
tools/rom_manifest_yellow.json; do
|
||||
grep -qxF "$required" "$LOVE_LIST" \
|
||||
|| fail "game.love is missing $required"
|
||||
done
|
||||
say "game.love: $(du -h "$LOVE_FILE" | cut -f1)"
|
||||
LOVE_FILE="$("$ROOT/scripts/pack_love.sh" --output "$LOVE_FILE" --listing "$LOVE_LIST")"
|
||||
|
||||
# ------------------------------------------------------- stamp release version
|
||||
# The working tree ships Version.lua with engine "0.0.0-dev"; the real release
|
||||
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
# Shared game.love packer for desktop and Switch builds.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/pack_love.sh [--output PATH] [--listing PATH] [--dry-run]
|
||||
# [--build-info PATH]
|
||||
#
|
||||
# Packs the same include/exclude set as the desktop release. Materializes a
|
||||
# listing file once and greps it (avoids SIGPIPE from unzip|grep under pipefail).
|
||||
#
|
||||
# --build-info PATH copy JSON into the love archive root before verification
|
||||
# --dry-run pack + verify only (for CI gates; no platform artifacts)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
WORK="$ROOT/.bazinga/work"
|
||||
OUTPUT="$WORK/game.love"
|
||||
LISTING="$WORK/love-listing.txt"
|
||||
DRY_RUN=0
|
||||
BUILD_INFO=""
|
||||
|
||||
say() { printf '\033[1;32m==>\033[0m %s\n' "$*"; }
|
||||
fail() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--output) OUTPUT="$2"; shift 2 ;;
|
||||
--listing) LISTING="$2"; shift 2 ;;
|
||||
--build-info) BUILD_INFO="$2"; shift 2 ;;
|
||||
--dry-run) DRY_RUN=1; shift ;;
|
||||
-h|--help)
|
||||
sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 0
|
||||
;;
|
||||
*) fail "unknown argument: $1" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p "$(dirname "$OUTPUT")" "$(dirname "$LISTING")"
|
||||
|
||||
say "packing game.love"
|
||||
rm -f "$OUTPUT"
|
||||
(cd "$ROOT" && zip -q -9 -r "$OUTPUT" \
|
||||
main.lua conf.lua src data assets tools/save-editor \
|
||||
tools/rom_manifest.json tools/rom_manifest_blue.json \
|
||||
tools/rom_manifest_yellow.json \
|
||||
-x '*.DS_Store' 'data/generated/*' 'assets/generated/*')
|
||||
|
||||
if [ -n "$BUILD_INFO" ]; then
|
||||
[ -f "$BUILD_INFO" ] || fail "missing build-info: $BUILD_INFO"
|
||||
[ "$(basename "$BUILD_INFO")" = "build-info.json" ] \
|
||||
|| fail "build-info file must be named build-info.json"
|
||||
(cd "$(dirname "$BUILD_INFO")" && zip -q "$OUTPUT" build-info.json)
|
||||
fi
|
||||
|
||||
# Materialize the listing once. Piping unzip→grep -q under `set -o pipefail`
|
||||
# SIGPIPEs unzip when grep exits early on a match and aborts the build.
|
||||
unzip -Z1 "$OUTPUT" > "$LISTING"
|
||||
if grep -Eq '^(data|assets)/generated/[^/]+|^(data|assets)/generated/.+/' "$LISTING"; then
|
||||
fail "game.love unexpectedly contains generated ROM data"
|
||||
fi
|
||||
|
||||
for required in tools/save-editor/App.lua tools/save-editor/Kit.lua \
|
||||
tools/save-editor/panels/Party.lua \
|
||||
tools/rom_manifest.json tools/rom_manifest_blue.json \
|
||||
tools/rom_manifest_yellow.json; do
|
||||
grep -qxF "$required" "$LISTING" \
|
||||
|| fail "game.love is missing $required"
|
||||
done
|
||||
|
||||
if [ -n "$BUILD_INFO" ]; then
|
||||
grep -qxF "build-info.json" "$LISTING" \
|
||||
|| fail "game.love is missing build-info.json"
|
||||
fi
|
||||
|
||||
say "game.love: $(du -h "$OUTPUT" | cut -f1)"
|
||||
|
||||
if [ "$DRY_RUN" -eq 1 ]; then
|
||||
say "pack dry-run OK: $OUTPUT"
|
||||
fi
|
||||
|
||||
printf '%s\n' "$OUTPUT"
|
||||
Reference in New Issue
Block a user