agb/justfile
Gwilym Inzani e8aed8e376
Backtraces (#590)
Implements a very basic backtrace and the ability to format them

If you run the panic example and press A, you get:

```
[ERROR] GBA Debug: [failed]
[ERROR] GBA Debug: debug data: ce3-1ee7-1fb7-24d-1ad
[FATAL] GBA Debug: Error: panicked at src/memory_mapped.rs:101:24:
index out of bounds: the len is 240 but the index is 240
```

which you can then prettify with:

```
> agb-addr2line ../target/thumbv4t-none-eabi/debug/examples/panic 0ce3-1f57-2027-024d-01ad
0:	rust_begin_unwind <agb>/lib.rs:321
1:	core::panicking::panic_nounwind <core>/panicking.rs:151
2:	core::panicking::assert_failed_inner <core>/panicking.rs:321
3:	agb::memory_mapped::MemoryMapped2DArray<T,_,_>::set <agb>/memory_mapped.rs:101
	(inlined by) agb::display::bitmap3::Bitmap3::draw_point <agb>/display/bitmap3.rs:31
4:	main /home/gwilym/Projects/agb/agb/examples/panic.rs:15
```

- [ ] Changelog updated / no changelog update needed
2024-04-09 20:25:15 +01:00

185 lines
5.8 KiB
Makefile

export CARGO_TARGET_DIR := env_var_or_default('CARGO_TARGET_DIR', justfile_directory() + "/target")
CLIPPY_ARGUMENTS := "-Dwarnings -Dclippy::all -Aclippy::empty-loop"
build: build-roms
build-debug:
just _build-debug agb
just _build-debug tracker/agb-tracker
build-release:
just _build-release agb
just _build-release tracker/agb-tracker
clippy:
just _all-crates _clippy
just _clippy tools
test:
just _test-debug agb
just _test-multiboot
just _test-debug agb-fixnum
just _test-debug agb-hashmap
just _test-debug tracker/agb-tracker
just _test-debug-arm agb
just _test-debug tools
just _test-debug emulator
test-release:
just _test-release agb
just _test-release agb-fixnum
just _test-release tracker/agb-tracker
just _test-release-arm agb
doctest-agb:
(cd agb && cargo test --doc -Z doctest-xcompile)
check-docs:
(cd agb && cargo doc --target=thumbv4t-none-eabi --no-deps)
(cd tracker/agb-tracker && cargo doc --target=thumbv4t-none-eabi --no-deps)
just _build_docs agb-fixnum
just _build_docs agb-hashmap
_build_docs crate:
(cd "{{crate}}" && cargo doc --no-deps)
clean:
just _all-crates _clean
fmt:
just _all-crates _fmt
just _fmt tools
fmt-check:
just _all-crates _fmt-check
just _fmt-check tools
run-example example:
just _build-example "{{example}}"
mgba-qt "$CARGO_TARGET_DIR/thumbv4t-none-eabi/debug/examples/{{example}}"
run-example-release example:
just _build-example-release "{{example}}"
mgba-qt "$CARGO_TARGET_DIR/thumbv4t-none-eabi/release/examples/{{example}}"
run-game game:
(cd "examples/{{game}}" && cargo run --release)
run-game-debug game:
(cd "examples/{{game}}" && cargo run)
ci: build-debug clippy fmt-check test miri build-release test-release doctest-agb test-games build-roms build-book check-docs
build-roms:
just _build-rom "examples/the-purple-night" "PURPLENIGHT"
just _build-rom "examples/the-hat-chooses-the-wizard" "HATWIZARD"
just _build-rom "examples/hyperspace-roll" "HYPERSPACE"
just _build-rom "examples/the-dungeon-puzzlers-lament" "DUNGLAMENT"
just _build-rom "examples/amplitude" "AMPLITUDE"
just _build-rom "examples/combo" "AGBGAMES"
just _build-rom "book/games/pong" "PONG"
(cd examples/target && zip examples.zip examples/*.gba)
build-book:
(cd book && mdbook build)
update-lockfiles *args:
bash .github/scripts/update-lockfiles.sh {{args}}
publish *args: (_run-tool "publish" args)
release +args: (_run-tool "release" args)
miri:
(cd agb-hashmap && cargo miri test)
build-mgba-wasm:
rm -rf website/agb/src/app/mgba/vendor
mkdir website/agb/src/app/mgba/vendor
podman build --file website/mgba-wasm/BuildMgbaWasm --output=website/agb/src/app/mgba/vendor .
build-combo-rom-site:
just _build-rom "examples/combo" "AGBGAMES"
build-site-app: build-mgba-wasm build-combo-rom-site
mkdir -p website/agb/public
gzip -9 -c examples/target/examples/combo.gba > website/agb/public/combo.gba.gz
(cd website/agb && npm install --no-save --prefer-offline --no-audit)
(cd website/agb && npm run build)
build-site: build-site-app build-book
rm -rf website/build
cp website/agb/out website/build -r
cp book/book website/build/book -r
_run-tool +tool:
(cd tools && cargo build)
"$CARGO_TARGET_DIR/debug/tools" {{tool}}
test-games:
just test-game the-dungeon-puzzlers-lament
test-game game:
(cd "examples/{{game}}" && CARGO_TARGET_THUMBV4T_NONE_EABI_RUNNER=mgba-test-runner cargo test)
_build-rom folder name:
#!/usr/bin/env bash
set -euxo pipefail
GAME_FOLDER="{{folder}}"
INTERNAL_NAME="{{name}}"
GAME_NAME="$(basename "$GAME_FOLDER")"
TARGET_FOLDER="${CARGO_TARGET_DIR:-$GAME_FOLDER/target}"
GBA_FILE="$TARGET_FOLDER/$GAME_NAME.gba"
(cd "$GAME_FOLDER" && cargo build --release --target thumbv4t-none-eabi && cargo clippy --release --target thumbv4t-none-eabi -- {{CLIPPY_ARGUMENTS}} && cargo fmt --all -- --check)
mkdir -p examples/target/examples
just gbafix --title "${INTERNAL_NAME:0:12}" --gamecode "${INTERNAL_NAME:0:4}" --makercode GC "$TARGET_FOLDER/thumbv4t-none-eabi/release/$GAME_NAME" -o "$GBA_FILE"
cp -v "$GBA_FILE" "examples/target/examples/$GAME_NAME.gba"
gbafix *args:
(cd agb-gbafix && cargo build --release && cd "{{invocation_directory()}}" && "$CARGO_TARGET_DIR/release/agb-gbafix" {{args}})
debug *args:
(cd agb-debug && cargo build --release && cd "{{invocation_directory()}}" && "$CARGO_TARGET_DIR/release/agb-debug" {{args}})
_all-crates target:
for CARGO_PROJECT_FILE in agb-*/Cargo.toml agb/Cargo.toml tracker/agb-*/Cargo.toml; do \
PROJECT_DIR=$(dirname "$CARGO_PROJECT_FILE"); \
just "{{target}}" "$PROJECT_DIR" || exit $?; \
done
_build-debug crate:
(cd "{{crate}}" && cargo build --examples --tests)
_build-release crate:
(cd "{{crate}}" && cargo build --release --examples --tests)
_test-release crate:
just _build-release {{crate}}
(cd "{{crate}}" && cargo test --release)
_test-release-arm crate:
(cd "{{crate}}" && cargo test --release --target=armv4t-none-eabi)
_test-debug crate:
just _build-debug {{crate}}
(cd "{{crate}}" && cargo test)
_test-debug-arm crate:
(cd "{{crate}}" && cargo test --target=armv4t-none-eabi)
_test-multiboot:
(cd "agb" && AGB_MULTIBOOT=true cargo test --features=multiboot --test=test_multiboot)
_clippy crate:
(cd "{{crate}}" && cargo clippy --examples --tests -- {{CLIPPY_ARGUMENTS}})
_clean crate:
(cd "{{crate}}" && cargo clean)
_fmt crate:
(cd "{{crate}}" && cargo fmt --all)
_fmt-check crate:
(cd "{{crate}}" && cargo fmt --all -- --check)
_build-example example:
(cd agb && cargo build "--example={{example}}")
_build-example-release example:
(cd agb && cargo build "--example={{example}}" --release)