oficina / slides Public

Clone
git clone https://amadan.net/oficina/slides

Plain git — no account needed to clone.

Download

Download this file

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