#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Assemble dist/: the static site, self-contained, served from any web root (play-gb's). # Usage: scripts/build-dist.sh (runs scripts/build-wasm.sh first) set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) cd "$ROOT" # The licences and notices page, from the build's dependency tree; stops the build when a # family crate has no LICENSE (BSD-3 and MIT ask for their notices with the binary). python3 -I scripts/notices.py scripts/build-wasm.sh # Start from an empty dist/ so a renamed or dropped file is not deployed by the --delete sync; # the old one is moved aside under target/ (the house rule: move aside, never delete). if [ -d dist ]; then mkdir -p target && mv dist "target/dist-previous-$(date +%Y%m%d-%H%M%S)"; fi mkdir -p dist/pkg cp web/index.html web/notices.html web/style.css web/app.js web/controls.js web/paddle-games.json web/audio-worklet.js web/icon.svg web/robots.txt web/manifest.json dist/ cp web/pkg/play_2600.js web/pkg/play_2600_bg.wasm dist/pkg/ # The licences that travel with the compiled board (MAME's BSD-3 palette tables among them). cp LICENSE dist/LICENSE.txt cp NOTICE dist/NOTICE.txt if [ -d web/games ]; then mkdir -p dist/games && cp web/games/* dist/games/; fi commit=$(git rev-parse --short HEAD 2>/dev/null || echo none)$(git diff --quiet HEAD -- . ':!dist' 2>/dev/null || echo "-dirty") board_dir=../a2600-rust-fast board="$(git -C "$board_dir" rev-parse --short=7 HEAD)$(git -C "$board_dir" diff --quiet HEAD -- . || echo -dirty) (path)" printf '{"commit": "%s", "board": "%s", "built": "%s"}\n' "$commit" "$board" "$(date -u +%Y-%m-%dT%H:%MZ)" > dist/version.json echo "dist/ built at $commit (board $board): $(find dist -type f | wc -l) files, $(du -sh dist | cut -f1)"