egui/build_example_web.sh

23 lines
568 B
Bash
Raw Normal View History

2020-11-17 22:24:14 +00:00
#!/bin/bash
set -eu
CRATE_NAME="example_web"
2020-11-17 22:24:14 +00:00
export RUSTFLAGS=--cfg=web_sys_unstable_apis # required for the clipboard API
# Clear output from old stuff:
rm -rf docs/$CRATE_NAME.wasm
2020-11-17 22:24:14 +00:00
echo "Building rust…"
BUILD=release
cargo build --release -p $CRATE_NAME --lib --target wasm32-unknown-unknown
2020-11-17 22:24:14 +00:00
echo "Generating JS bindings for wasm…"
TARGET_NAME="$CRATE_NAME.wasm"
2020-11-17 22:24:14 +00:00
wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
--out-dir docs --no-modules --no-typescript
echo "Finished: docs/$CRATE_NAME.wasm"
2020-11-17 22:24:14 +00:00
open http://localhost:8888/example.html