fix(web): make wasm builds reproducible so the freshness gate passes
The web-wasm-freshness gate (#93) false-failed because the Bevy wasm build baked in machine-specific absolute source paths — the cargo registry (/home/<user>/.cargo/registry/...), the rustup std sources (~/.rustup/...), and this checkout — so CI's rebuild (under /workspace, /root) never matched the committed bytes even with identical pinned tool versions. build_wasm.sh now exports CARGO_ENCODED_RUSTFLAGS with three --remap-path-prefix rules (cargo home -> /cargo, rustup home -> /rustup, repo -> /build) so the embedded paths are identical on any machine. It re-states the getrandom_backend cfg because a *_RUSTFLAGS env var replaces (not merges with) .cargo/config.toml's target rustflags. Regenerated all four artifacts with the remap applied — verified zero machine-specific paths remain (only canonical /cargo + /rustup prefixes), which is the precondition for the gate's byte-for-byte rebuild-and-diff to match across machines. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user