Scripts Take Rom as Arg (#512)
* initial * suggestions for get_memory_map.sh * CONTRIBUTING.md suggestions * save_build.sh suggestions * rerun * env variable * add to env * print usage and remove redundant qoutes
This commit is contained in:
+25
-6
@@ -5,21 +5,41 @@
|
||||
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") <rom-file> [build-label]"
|
||||
echo " <rom-file> Path to the .gba ROM file (e.g. build/balatro-gba.gba)"
|
||||
echo " [build-label] Optional label for the saved build directory (default: \"build\")"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
ROM_FILE="$1"
|
||||
|
||||
make
|
||||
|
||||
GAME_NAME="${GAME_NAME-balatro-gba}"
|
||||
if [ ! -f "$ROM_FILE" ]; then
|
||||
echo "Error: ROM file not found or is not a regular file: $ROM_FILE"
|
||||
usage
|
||||
fi
|
||||
|
||||
# Derive the game base name from the ROM file (strip directory and .gba extension)
|
||||
GAME_NAME="$(basename "$ROM_FILE" .gba)"
|
||||
timestamp=$(date +%Y%m%d_%H%M%S)
|
||||
arg=${1:-"build"}
|
||||
arg="${2:-build}"
|
||||
dir="saved_builds/${arg}_${timestamp}"
|
||||
|
||||
mkdir -p "$dir"
|
||||
|
||||
failed=0
|
||||
for fe in elf gba map; do
|
||||
if [ -f build/"$GAME_NAME".$fe ]; then
|
||||
cp build/"$GAME_NAME".$fe "$dir/"
|
||||
src="$(dirname "$ROM_FILE")/${GAME_NAME}.${fe}"
|
||||
if [ -f "$src" ]; then
|
||||
cp "$src" "$dir/"
|
||||
else
|
||||
echo "Warning: build/$GAME_NAME.$fe not found"
|
||||
echo "Warning: $src not found"
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
@@ -31,4 +51,3 @@ else
|
||||
fi
|
||||
|
||||
exit $failed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user