2022-02-25 08:54:16 +11:00
export CARGO_TARGET_DIR := env_var_or_default( 'CARGO_TARGET_DIR' , justfile_directory( ) + "/target" )
2022-04-25 02:07:43 +10:00
CLIPPY_ARGUMENTS := "-Dwarnings -Dclippy::all -Aclippy::empty-loop"
2022-02-25 08:54:16 +11:00
2024-04-29 10:57:32 +10:00
podman_command := "podman"
2022-02-25 08:35:02 +11:00
build : build -roms
2022-02-25 08:29:33 +11:00
2022-04-24 02:10:17 +10:00
build-debug :
2024-04-21 05:28:17 +10:00
( cd agb && cargo build --no-default-features)
( cd agb && cargo build --no-default-features --features= testing)
( cd agb && cargo build --examples --tests)
( cd tracker/agb-tracker && cargo build --examples --tests)
2022-04-24 02:10:17 +10:00
build-release :
2024-04-21 05:28:17 +10:00
( cd agb && cargo build --examples --tests --release)
2022-04-24 02:10:17 +10:00
clippy :
just _all-crates _clippy
2022-02-25 08:54:16 +11:00
test :
2024-10-30 22:08:49 +11:00
# test the workspace
cargo test
# also need to explicitly hit the serde tests in agb-hashmap
( cd agb-hashmap && cargo test --features= serde serde)
2022-04-24 02:10:17 +10:00
just _test-debug agb
2023-07-23 09:31:12 +10:00
just _test-debug tracker/agb-tracker
2024-04-21 05:28:17 +10:00
just _test-multiboot
2022-08-02 02:36:12 +10:00
just _test-debug-arm agb
2022-04-24 02:10:17 +10:00
test-release :
just _test-release agb
2023-07-24 05:36:54 +10:00
just _test-release tracker/agb-tracker
2022-08-02 02:36:12 +10:00
just _test-release-arm agb
2022-02-25 08:54:16 +11:00
2022-07-12 23:37:17 +10:00
doctest-agb :
( cd agb && cargo test --doc -Z doctest-xcompile)
2022-10-13 03:29:20 +11:00
check-docs :
2023-07-24 04:52:11 +10:00
( cd agb && cargo doc --target= thumbv4t-none-eabi --no-deps)
( cd tracker/agb-tracker && cargo doc --target= thumbv4t-none-eabi --no-deps)
2024-04-10 06:06:21 +10:00
cargo doc --no-deps
2022-10-13 03:29:20 +11:00
2024-04-17 05:19:57 +10:00
validate-renovate :
npx --yes --package renovate -- renovate-config-validator
2022-10-13 03:29:20 +11:00
_build_docs crate :
2022-12-10 08:18:15 +11:00
( cd "{{crate}}" && cargo doc --no-deps)
2022-10-13 03:29:20 +11:00
2022-02-25 08:54:16 +11:00
clean :
just _all-crates _clean
2023-03-24 08:43:19 +11:00
fmt :
just _all-crates _fmt
2024-04-10 06:06:21 +10:00
2023-03-24 08:43:19 +11:00
fmt-check :
just _all-crates _fmt-check
2022-02-25 09:07:28 +11:00
run-example example :
just _build-example "{{example}}"
mgba-qt " $CARGO_TARGET_DIR /thumbv4t-none-eabi/debug/examples/{{example}} "
2022-02-25 09:08:36 +11:00
run-example-release example :
just _build-example-release "{{example}}"
mgba-qt " $CARGO_TARGET_DIR /thumbv4t-none-eabi/release/examples/{{example}} "
2022-02-25 09:19:25 +11:00
run-game game :
( cd "examples/{{game}}" && cargo run --release)
run-game-debug game :
( cd "examples/{{game}}" && cargo run)
2023-10-18 22:09:01 +11:00
ci : build -debug clippy fmt -check test miri build -release test -release doctest -agb test -games build -roms build -book check -docs
2022-02-25 08:29:33 +11:00
2022-02-25 08:35:02 +11:00
build-roms :
2022-02-25 08:29:33 +11:00
just _build-rom "examples/the-purple-night" "PURPLENIGHT"
just _build-rom "examples/the-hat-chooses-the-wizard" "HATWIZARD"
2022-07-25 06:35:28 +10:00
just _build-rom "examples/hyperspace-roll" "HYPERSPACE"
2023-07-26 05:27:03 +10:00
just _build-rom "examples/the-dungeon-puzzlers-lament" "DUNGLAMENT"
2023-04-26 10:37:37 +10:00
just _build-rom "examples/amplitude" "AMPLITUDE"
just _build-rom "examples/combo" "AGBGAMES"
2022-02-25 08:29:33 +11:00
just _build-rom "book/games/pong" "PONG"
( cd examples/target && zip examples.zip examples/*.gba)
2022-02-25 08:36:18 +11:00
build-book :
( cd book && mdbook build)
2023-08-07 06:04:58 +10:00
update-lockfiles *args :
bash .github/scripts/update-lockfiles.sh { { args} }
2022-02-25 08:37:22 +11:00
2023-04-13 00:12:00 +10:00
publish *args : (_run -tool "publish " args )
2022-08-05 06:30:52 +10:00
2022-10-03 03:55:05 +11:00
release +args : (_run -tool "release " args )
2023-04-24 02:46:00 +10:00
miri :
( cd agb-hashmap && cargo miri test )
2024-04-18 09:50:13 +10:00
setup-cargo-wasm :
cargo install wasm-pack
2024-04-20 06:12:46 +10:00
build-website-backtrace :
( cd website/backtrace && wasm-pack build --target web)
2024-04-29 07:52:59 +10:00
rm -rf website/agb/src/vendor/backtrace
mkdir -p website/agb/src/vendor
cp website/backtrace/pkg website/agb/src/vendor/backtrace -r
2024-04-18 09:50:13 +10:00
2024-04-04 08:58:10 +11:00
build-mgba-wasm :
2024-04-29 07:52:59 +10:00
rm -rf website/agb/src/components/mgba/vendor
mkdir website/agb/src/components/mgba/vendor
{ { podman_command} } build --file website/mgba-wasm/BuildMgbaWasm --output= website/agb/src/components/mgba/vendor .
2024-04-04 08:58:10 +11:00
2024-04-04 11:07:10 +11:00
build-combo-rom-site :
just _build-rom "examples/combo" "AGBGAMES"
2024-04-29 08:29:57 +10:00
mkdir -p website/agb/src/roms
gzip -9 -c examples/target/examples/combo.gba > website/agb/src/roms/combo.gba.gz
2024-04-18 09:50:13 +10:00
2024-05-22 11:21:30 +10:00
generate-screenshot *args :
( cd emulator/screenshot-generator && cargo build --release && cd "{{invocation_directory()}}" && " $CARGO_TARGET_DIR /release/screenshot-generator " { { args} } )
2024-04-18 09:50:13 +10:00
2024-05-22 11:21:30 +10:00
build-site-examples : build -release
#!/usr/bin/env bash
set -euxo pipefail
mkdir -p website/agb/src/roms/examples
EXAMPLES = " $( cd agb/examples; ls *.rs) "
EXAMPLE_DEFINITIONS = "export const Examples: {url: URL, example_name: string, screenshot: StaticImageData }[] = [" > website/agb/src/roms/examples/examples.ts
EXAMPLE_IMAGE_IMPORTS = "import { StaticImageData } from 'next/image';" ;
for EXAMPLE_NAME in $EXAMPLES ; do
EXAMPLE = " ${ EXAMPLE_NAME %.rs } "
just gbafix " $CARGO_TARGET_DIR /thumbv4t-none-eabi/release/examples/ $EXAMPLE " --output= " $CARGO_TARGET_DIR /thumbv4t-none-eabi/release/examples/ $EXAMPLE .gba "
gzip -9 -c $CARGO_TARGET_DIR /thumbv4t-none-eabi/release/examples/$EXAMPLE .gba > website/agb/src/roms/examples/$EXAMPLE .gba.gz
just generate-screenshot --rom= " $CARGO_TARGET_DIR /thumbv4t-none-eabi/release/examples/ $EXAMPLE .gba " --frames= 10 --output= website/agb/src/roms/examples/$EXAMPLE .png
EXAMPLE_IMAGE_IMPORTS = " $EXAMPLE_IMAGE_IMPORTS import $EXAMPLE from './ $EXAMPLE .png'; "
EXAMPLE_DEFINITIONS = " $EXAMPLE_DEFINITIONS {url: new URL('./ $EXAMPLE .gba.gz', import.meta.url), example_name: ' $EXAMPLE ', screenshot: $EXAMPLE }, "
done
EXAMPLE_DEFINITIONS = " $EXAMPLE_DEFINITIONS ]; "
echo " $EXAMPLE_IMAGE_IMPORTS " > website/agb/src/roms/examples/examples.ts
echo " $EXAMPLE_DEFINITIONS " >> website/agb/src/roms/examples/examples.ts
2024-05-22 21:45:39 +10:00
setup-app-build : build -mgba -wasm build -combo -rom -site build -website -backtrace build -site -examples
2024-04-09 09:18:22 +10:00
( cd website/agb && npm install --no-save --prefer-offline --no-audit)
2024-04-18 09:50:13 +10:00
build-site-app : setup -app -build
2024-04-09 09:18:22 +10:00
( cd website/agb && npm run build)
2024-04-04 11:07:10 +11:00
2024-04-18 09:50:13 +10:00
serve-site-dev : setup -app -build
( cd website/agb && npm run dev)
2024-04-09 09:18:22 +10:00
build-site : build -site -app build -book
2024-04-04 11:07:10 +11:00
rm -rf website/build
2024-04-09 09:18:22 +10:00
cp website/agb/out website/build -r
2024-04-04 11:07:10 +11:00
cp book/book website/build/book -r
2022-08-05 06:30:52 +10:00
_run-tool +tool :
2022-10-03 03:53:42 +11:00
( cd tools && cargo build)
2022-10-03 04:19:14 +11:00
" $CARGO_TARGET_DIR /debug/tools " { { tool} }
2022-08-05 06:30:52 +10:00
2023-09-14 21:29:13 +10:00
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 )
2022-02-25 08:29:33 +11:00
_build-rom folder name :
#!/usr/bin/env bash
2022-02-25 08:35:02 +11:00
set -euxo pipefail
2022-02-25 08:29:33 +11:00
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 "
2023-03-24 08:43:19 +11:00
( cd " $GAME_FOLDER " && cargo build --release --target thumbv4t-none-eabi && cargo clippy --release --target thumbv4t-none-eabi -- { { CLIPPY_ARGUMENTS} } && cargo fmt --all -- --check)
2022-02-25 08:29:33 +11:00
mkdir -p examples/target/examples
2023-04-09 06:18:27 +10:00
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 "
2022-02-25 08:29:33 +11:00
cp -v " $GBA_FILE " " examples/target/examples/ $GAME_NAME .gba "
2023-04-09 06:14:11 +10:00
gbafix *args :
2024-04-04 00:18:54 +11:00
( cd agb-gbafix && cargo build --release && cd "{{invocation_directory()}}" && " $CARGO_TARGET_DIR /release/agb-gbafix " { { args} } )
2024-04-10 05:15:33 +10:00
debug *args :
( cd agb-debug && cargo build --release && cd "{{invocation_directory()}}" && " $CARGO_TARGET_DIR /release/agb-debug " { { args} } )
2023-04-09 06:10:47 +10:00
2022-02-25 08:29:33 +11:00
_all-crates target :
2024-04-10 06:06:21 +10:00
for CARGO_PROJECT_FILE in agb/Cargo.toml tracker/agb-tracker/Cargo.toml ./Cargo.toml; do \
2022-02-25 08:29:33 +11:00
PROJECT_DIR = $( dirname " $CARGO_PROJECT_FILE " ) ; \
2022-03-14 07:10:37 +11:00
just "{{target}}" " $PROJECT_DIR " || exit $? ; \
2022-02-25 08:29:33 +11:00
done
_test-release crate :
2022-04-24 02:10:17 +10:00
( cd "{{crate}}" && cargo test --release)
2022-08-02 02:36:12 +10:00
_test-release-arm crate :
2022-08-23 21:44:54 +10:00
( cd "{{crate}}" && cargo test --release --target= armv4t-none-eabi)
2022-02-25 08:29:33 +11:00
_test-debug crate :
2022-04-24 02:10:17 +10:00
( cd "{{crate}}" && cargo test )
2022-08-02 02:36:12 +10:00
_test-debug-arm crate :
2022-08-24 11:52:32 +10:00
( cd "{{crate}}" && cargo test --target= armv4t-none-eabi)
2023-10-18 09:49:57 +11:00
_test-multiboot :
2023-10-18 22:26:50 +11:00
( cd "agb" && AGB_MULTIBOOT = true cargo test --features= multiboot --test= test_multiboot)
2022-02-25 08:29:33 +11:00
_clippy crate :
2022-04-25 02:07:43 +10:00
( cd "{{crate}}" && cargo clippy --examples --tests -- { { CLIPPY_ARGUMENTS} } )
2022-02-25 08:54:16 +11:00
_clean crate :
( cd "{{crate}}" && cargo clean)
2023-03-24 08:43:19 +11:00
_fmt crate :
( cd "{{crate}}" && cargo fmt --all)
_fmt-check crate :
( cd "{{crate}}" && cargo fmt --all -- --check)
2022-02-25 09:07:28 +11:00
_build-example example :
2022-02-25 09:08:36 +11:00
( cd agb && cargo build "--example={{example}}" )
_build-example-release example :
2022-08-24 11:52:32 +10:00
( cd agb && cargo build "--example={{example}}" --release)