diff --git a/build_wasm.sh b/build_wasm.sh index 46d0be6..995d17d 100755 --- a/build_wasm.sh +++ b/build_wasm.sh @@ -22,6 +22,22 @@ set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" OUT_DIR="$REPO_ROOT/solitaire_server/web/pkg" +# Reproducible builds. The wasm artifacts otherwise bake in machine-specific +# absolute source paths (the cargo registry, the rustup std sources, and this +# checkout), so a rebuild on a different machine produces different bytes and +# the CI freshness gate (rebuild-and-diff) false-positives. Remap all three +# prefixes to fixed names so the output is byte-identical anywhere. +# +# We must use CARGO_ENCODED_RUSTFLAGS (not RUSTFLAGS) and re-state the +# getrandom backend cfg here: a `*_RUSTFLAGS` env var *replaces* — does not +# merge with — the `[target.wasm32-unknown-unknown] rustflags` in +# .cargo/config.toml, so dropping that cfg would break the wasm getrandom build. +# Keep this `--cfg` in sync with .cargo/config.toml. +CARGO_HOME_DIR="${CARGO_HOME:-$HOME/.cargo}" +RUSTUP_HOME_DIR="${RUSTUP_HOME:-$HOME/.rustup}" +US=$'\x1f' # unit separator: CARGO_ENCODED_RUSTFLAGS arg delimiter +export CARGO_ENCODED_RUSTFLAGS="--cfg${US}getrandom_backend=\"wasm_js\"${US}--remap-path-prefix=${CARGO_HOME_DIR}=/cargo${US}--remap-path-prefix=${RUSTUP_HOME_DIR}=/rustup${US}--remap-path-prefix=${REPO_ROOT}=/build" + if ! command -v wasm-pack &> /dev/null; then echo "error: wasm-pack not found." >&2 echo " Install with: cargo install wasm-pack" >&2 diff --git a/solitaire_server/web/pkg/canvas_bg.wasm b/solitaire_server/web/pkg/canvas_bg.wasm index e773eb8..9636109 100644 Binary files a/solitaire_server/web/pkg/canvas_bg.wasm and b/solitaire_server/web/pkg/canvas_bg.wasm differ diff --git a/solitaire_server/web/pkg/solitaire_wasm_bg.wasm b/solitaire_server/web/pkg/solitaire_wasm_bg.wasm index cb078cf..2376852 100644 Binary files a/solitaire_server/web/pkg/solitaire_wasm_bg.wasm and b/solitaire_server/web/pkg/solitaire_wasm_bg.wasm differ