From a2dea3cab596fd91bdb3dea25c27de886eea2778 Mon Sep 17 00:00:00 2001 From: Corwin Date: Wed, 22 May 2024 02:21:30 +0100 Subject: [PATCH] generate roms and screenshots --- justfile | 29 ++++++++++++++++++++++++++++- website/agb/.gitignore | 3 ++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 95e4a4b6..1d71bd55 100644 --- a/justfile +++ b/justfile @@ -112,8 +112,35 @@ build-combo-rom-site: mkdir -p website/agb/src/roms gzip -9 -c examples/target/examples/combo.gba > website/agb/src/roms/combo.gba.gz +generate-screenshot *args: + (cd emulator/screenshot-generator && cargo build --release && cd "{{invocation_directory()}}" && "$CARGO_TARGET_DIR/release/screenshot-generator" {{args}}) -setup-app-build: build-mgba-wasm build-combo-rom-site build-website-backtrace + +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 + + +setup-app-build: build-mgba-wasm build-combo-rom-site build-website-backtrace build-site-examples: (cd website/agb && npm install --no-save --prefer-offline --no-audit) build-site-app: setup-app-build diff --git a/website/agb/.gitignore b/website/agb/.gitignore index ccbe9f5d..9fabce27 100644 --- a/website/agb/.gitignore +++ b/website/agb/.gitignore @@ -38,4 +38,5 @@ next-env.d.ts vendor *.gba -*.gba.gz \ No newline at end of file +*.gba.gz +src/roms \ No newline at end of file