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:
@@ -67,7 +67,11 @@ jobs:
|
|||||||
echo "GID=$(id -g)" >> "$GITHUB_ENV"
|
echo "GID=$(id -g)" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Build the project
|
- name: Build the project
|
||||||
run: docker compose -f docker-compose.yml run --rm gbalatro sh -c "make -j$(nproc) && ./scripts/get_memory_map.sh"
|
run: |
|
||||||
|
docker compose -f docker-compose.yml run --rm \
|
||||||
|
-e PATH=/opt/devkitpro/devkitARM/bin:/opt/devkitpro/tools/bin:$PATH \
|
||||||
|
gbalatro \
|
||||||
|
sh -c "make -j\$(nproc) && ./scripts/get_memory_map.sh build/balatro-gba.elf"
|
||||||
|
|
||||||
- name: 'Upload Artifact'
|
- name: 'Upload Artifact'
|
||||||
if: ${{ inputs.upload-build-artifact }}
|
if: ${{ inputs.upload-build-artifact }}
|
||||||
|
|||||||
+7
-1
@@ -138,7 +138,13 @@ In the repo we use custom scripts located in the [`scripts`](https://github.com/
|
|||||||
- **get_hash.py**: Get git hash from ROM.
|
- **get_hash.py**: Get git hash from ROM.
|
||||||
- **generate_font.py**: Generate a font manually.
|
- **generate_font.py**: Generate a font manually.
|
||||||
- **get_memory_map.sh**: Print the memory map of the pre-allocated pools.
|
- **get_memory_map.sh**: Print the memory map of the pre-allocated pools.
|
||||||
- **save_build.sh**: Save a timestamped copy of build outputs (.elf, .gba, .map).
|
- **save_build.sh**: Save a timestamped copy of build outputs (`.elf`, `.gba`, `.map`).
|
||||||
|
# Minimal usage
|
||||||
|
./scripts/save_build.sh build/balatro-gba.gba
|
||||||
|
|
||||||
|
# With optional build label
|
||||||
|
./scripts/save_build.sh build/balatro-gba.gba my-feature
|
||||||
|
```
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
It's recommended to use [mGBA](https://mgba.io/) for ROM testing and debugging. As it provides a [`gdbserver`](https://en.wikipedia.org/wiki/Gdbserver) via the `-g` flag `mgba -g build/balatro-gba.gba`. You can connect via `gdb` or here is a [great guide for vscode](https://felixjones.co.uk/mgba_gdb/vscode.html).
|
It's recommended to use [mGBA](https://mgba.io/) for ROM testing and debugging. As it provides a [`gdbserver`](https://en.wikipedia.org/wiki/Gdbserver) via the `-g` flag `mgba -g build/balatro-gba.gba`. You can connect via `gdb` or here is a [great guide for vscode](https://felixjones.co.uk/mgba_gdb/vscode.html).
|
||||||
|
|||||||
+23
-17
@@ -2,30 +2,36 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ELF_FILE="${ELF_FILE-./build/balatro-gba.elf}"
|
usage() {
|
||||||
POOL_DEF_FILE="${POOL_DEF_FILE-./include/def_balatro_mempool.h}"
|
echo "Usage: $(basename "$0") <elf-file> [pool-def-file]"
|
||||||
READELF="${READELF-/opt/devkitpro/devkitARM/bin/arm-none-eabi-readelf}"
|
echo " <elf-file> Path to the built .elf file (e.g. build/balatro-gba.elf)"
|
||||||
|
echo " [pool-def-file] Path to the mempool definition header"
|
||||||
|
echo " (default: ./include/def_balatro_mempool.h)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
ELF_FILE="$1"
|
||||||
|
POOL_DEF_FILE="${2-./include/def_balatro_mempool.h}"
|
||||||
|
READELF="${READELF:-arm-none-eabi-readelf}"
|
||||||
TOTAL_BYTES=0
|
TOTAL_BYTES=0
|
||||||
|
|
||||||
if [ ! -f "$POOL_DEF_FILE" ]; then
|
if [ ! -f "$POOL_DEF_FILE" ]; then
|
||||||
echo "Mempool definition file not found: $POOL_DEF_FILE"
|
echo "Mempool definition file not found: $POOL_DEF_FILE"
|
||||||
echo "You can set your mempool definition file with:"
|
usage
|
||||||
echo " POOL_DEF_FILE=<mempool-def-file> $(basename $0)"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$ELF_FILE" ]; then
|
if [ ! -f "$ELF_FILE" ]; then
|
||||||
echo "elf file not found: $ELF_FILE"
|
echo "ELF file not found or is not a regular file: $ELF_FILE"
|
||||||
echo "You can set your elf file with:"
|
usage
|
||||||
echo " ELF_FILE=<elf-file> $(basename $0)"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -x "$READELF" ]; then
|
if ! command -v "$READELF" >/dev/null 2>&1; then
|
||||||
echo "ERROR: \"$READELF\" is not an executable file."
|
echo "ERROR: missing tool: $READELF"
|
||||||
echo "You can override the file location for 'arm-none-eabi-readelf' with the READELF env variable."
|
usage
|
||||||
echo " e.g. $ READELF=\"/my/custom/location/arm-none-eabi-readelf\" $(basename $0) <file>"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_line_break() {
|
print_line_break() {
|
||||||
@@ -67,7 +73,7 @@ for name in $(get_pool_names); do
|
|||||||
pool_size="$(cut -d ' ' -f 3 <<< $output_pool)"
|
pool_size="$(cut -d ' ' -f 3 <<< $output_pool)"
|
||||||
func_size="$(cut -d ' ' -f 3 <<< $output_func)"
|
func_size="$(cut -d ' ' -f 3 <<< $output_func)"
|
||||||
bitset_size="$(cut -d ' ' -f 3 <<< $output_bitset)"
|
bitset_size="$(cut -d ' ' -f 3 <<< $output_bitset)"
|
||||||
|
|
||||||
TOTAL_BYTES=$(( TOTAL_BYTES + pool_size + func_size + bitset_size ))
|
TOTAL_BYTES=$(( TOTAL_BYTES + pool_size + func_size + bitset_size ))
|
||||||
|
|
||||||
printf "%-16s| 0x%8s | %-10u | %-10u | %-10u \n" "$name" "$address" "$pool_size" "$func_size" "$bitset_size"
|
printf "%-16s| 0x%8s | %-10u | %-10u | %-10u \n" "$name" "$address" "$pool_size" "$func_size" "$bitset_size"
|
||||||
|
|||||||
+25
-6
@@ -5,21 +5,41 @@
|
|||||||
|
|
||||||
set -e
|
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
|
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)
|
timestamp=$(date +%Y%m%d_%H%M%S)
|
||||||
arg=${1:-"build"}
|
arg="${2:-build}"
|
||||||
dir="saved_builds/${arg}_${timestamp}"
|
dir="saved_builds/${arg}_${timestamp}"
|
||||||
|
|
||||||
mkdir -p "$dir"
|
mkdir -p "$dir"
|
||||||
|
|
||||||
failed=0
|
failed=0
|
||||||
for fe in elf gba map; do
|
for fe in elf gba map; do
|
||||||
if [ -f build/"$GAME_NAME".$fe ]; then
|
src="$(dirname "$ROM_FILE")/${GAME_NAME}.${fe}"
|
||||||
cp build/"$GAME_NAME".$fe "$dir/"
|
if [ -f "$src" ]; then
|
||||||
|
cp "$src" "$dir/"
|
||||||
else
|
else
|
||||||
echo "Warning: build/$GAME_NAME.$fe not found"
|
echo "Warning: $src not found"
|
||||||
failed=1
|
failed=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -31,4 +51,3 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
exit $failed
|
exit $failed
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user