#!/usr/bin/env bash # Assemble dist/: the static site, self-contained, served from any web root. # Usage: scripts/build-dist.sh (runs scripts/build-wasm.sh first; BOARD=... as there) set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) cd "$ROOT" scripts/build-wasm.sh # The licences and notices page, from the build's dependency tree as build-wasm.sh resolved it # (the staged base board, whose licence files are read from the checkout it was staged from); # stops the build when a family crate has no LICENSE (BSD-3, ISC and MIT ask for their # notices with the binary). python3 -I scripts/notices.py --config 'paths=["target/board"]' \ --source-dir "pcengine-rust=$(cat target/board.path)" mkdir -p dist/pkg cp web/index.html web/notices.html web/style.css web/app.js web/controls.js web/worker.js web/audio-worklet.js web/icon.svg web/robots.txt web/manifest.json dist/ cp web/pkg/play_pce.js web/pkg/play_pce_bg.wasm dist/pkg/ commit=$(git rev-parse --short HEAD 2>/dev/null || echo none)$(git diff --quiet HEAD -- . ':!dist' 2>/dev/null || echo "-dirty") # The boards' commits: the base board from the checkout it was staged from (BOARD), the # add-ons from their git pins in Cargo.lock. at() { echo "$(basename "$1") $(git -C "$1" rev-parse --short HEAD 2>/dev/null || echo "?")$(git -C "$1" diff --quiet HEAD -- . 2>/dev/null || echo -dirty)"; } pinned() { echo "$1 $(grep -A2 "^name = \"$1\"" Cargo.lock | grep -o 'rev=[0-9a-f]*' | head -1 | cut -c5-11)"; } base=$(cat target/board.path) boards="$(at "$base"), $(pinned supergrafx-rust), $(pinned pcenginecd-rust)" printf '{"commit": "%s", "boards": "%s", "built": "%s"}\n' "$commit" "$boards" "$(date -u +%Y-%m-%dT%H:%MZ)" > dist/version.json echo "dist/ built at $commit ($boards): $(find dist -type f | wc -l) files, $(du -sh dist | cut -f1)"