#!/usr/bin/env bash # Build the PDF crate (core/pdf) for wazero, the same way build-wasm.sh # builds the CRDT core: plain wasm32 with a C ABI, no wasm-bindgen, no # wasm-pack, no host imports. set -euo pipefail cd "$(dirname "$0")/.." cargo clippy --manifest-path core/pdf/Cargo.toml --all-targets -- -D warnings # --lib only: the module shipped to wazero is the library crate. # # --remap-path-prefix (x2): see build-wasm.sh. rustc bakes the absolute # path of every panic site into the binary; remapping the registry and # this checkout to fixed placeholders makes the artefact reproducible # across machines and $HOMEs, which the gate's byte comparison against # the committed copy depends on. # # The root .cargo/config.toml's rustflags for this target (the getrandom # custom-backend cfg) are replaced, not extended, by an env RUSTFLAGS, so # they are repeated here. This crate has no getrandom in its graph (see # core/pdf/Cargo.toml) and the cfg is inert for it, but keeping the flags # identical to build-wasm.sh means the two modules are built under one set # of rules rather than two that could drift. registry_root="${CARGO_HOME:-$HOME/.cargo}/registry/src" workspace_root="$(pwd)" export RUSTFLAGS="--cfg getrandom_backend=\"custom\" --remap-path-prefix=${registry_root}=/cargo-registry-src --remap-path-prefix=${workspace_root}=/slides-pdf" cargo build --release --manifest-path core/pdf/Cargo.toml --target wasm32-unknown-unknown --locked --lib out="core/pdf/target/wasm32-unknown-unknown/release/slides_pdf.wasm" [ -f "$out" ] || { echo "build-pdf-wasm: no artifact at $out" >&2; exit 1; } echo "$out ($(wc -c < "$out") bytes)"