chore(workspace): Rust workspace R0 — builder image, core crate (JS-compatible JSON, report contracts, facade), wasm facade, core-wasm package with proofs
This commit is contained in:
1 parent
5fec0654d3
commit
2a38fa37b5
39 files changed
+1913
-1
No files matched your search
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the browser module of crates/wasm into packages/core-wasm/pkg (git-ignored).
|
||||
# Runs inside the builder image: `pnpm wasm:build` or `bash docker/rust-run.sh bash docker/wasm-build.sh`.
|
||||
# The wasm-bindgen CLI must be the exact version of the wasm-bindgen crate in Cargo.lock
|
||||
# (wasm-bindgen >= 0.2.128 refuses a mismatch at runtime; we refuse it up front).
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
lock_version="$(awk '/^name = "wasm-bindgen"$/ { getline; sub(/^version = "/, ""); sub(/"$/, ""); print; exit }' Cargo.lock)"
|
||||
cli_version="$(wasm-bindgen --version | awk '{ print $2 }')"
|
||||
if [ "$lock_version" != "$cli_version" ]; then
|
||||
echo "wasm-bindgen crate ${lock_version} (Cargo.lock) != wasm-bindgen-cli ${cli_version} (builder image)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo build -p faunosteo-wasm --release --target wasm32-unknown-unknown --locked
|
||||
|
||||
out=packages/core-wasm/pkg
|
||||
rm -rf "$out"
|
||||
wasm-bindgen --target web --out-dir "$out" --out-name faunosteo_wasm \
|
||||
target/wasm32-unknown-unknown/release/faunosteo_wasm.wasm
|
||||
|
||||
raw=$(wc -c < "$out/faunosteo_wasm_bg.wasm")
|
||||
gz=$(gzip -9 -c "$out/faunosteo_wasm_bg.wasm" | wc -c)
|
||||
echo "faunosteo_wasm_bg.wasm: ${raw} bytes raw, ${gz} bytes gzip -9"
|
||||
Reference in new issue
Block a user