#!/bin/sh # Build the browser version of MRPCI into web/dist/ (self-contained, static). # Requires the wasm target: rustup target add wasm32-unknown-unknown # # ./web/build.sh # bakes games/neon-precinct # ./web/build.sh /path/to/game # bake any game folder instead # # The browser build is a PLAYER: it boots straight into the game and the F8 # editor toggle is compiled out. Authoring stays on the desktop. # # Unlike MRPGI's build, which embeds a game *folder* with include_dir!, this # bakes a single WorldBundle JSON — the same document `--export-bundle` # writes and the MRP3GI bridge boots from. One format, three engines, and the # page can hand the engine another one at runtime. set -e cd "$(dirname "$0")/.." GAME="${1:-games/neon-precinct}" BUNDLE="web/game.bundle.json" echo "baking game: $GAME" cargo build --release -p mrpci-core --bin mrpci-headless ./target/release/mrpci-headless --game "$GAME" --export-bundle "$BUNDLE" # include_str! reads the path at compile time; make sure the crate recompiles # when only the bundle changed. touch mrpci/src/main.rs cargo build -p mrpci --release --target wasm32-unknown-unknown rm -rf web/dist mkdir -p web/dist cp target/wasm32-unknown-unknown/release/mrpci.wasm web/dist/ cp web/index.html web/mq_js_bundle.js web/dist/ # A game's own sfx/ and music/ ride along if it has them; the engine falls # back to its built-in synth for anything missing, so this is optional. for kind in sfx music; do if [ -d "$GAME/$kind" ]; then mkdir -p "web/dist/game/$kind" cp "$GAME/$kind"/*.wav "$GAME/$kind"/*.ogg "$GAME/$kind"/*.mp3 \ "web/dist/game/$kind/" 2>/dev/null || true fi done echo "web build ready: $(du -sh web/dist | cut -f1) in web/dist/"