2018-12-24 02:42:30 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
|
2020-12-30 00:54:52 +08:00
|
|
|
CRATE_NAME="egui_demo_app"
|
2018-12-24 02:42:30 +08:00
|
|
|
|
2020-12-29 19:42:15 +08:00
|
|
|
# This is required to enable the web_sys clipboard API which egui_web uses
|
|
|
|
# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
|
|
|
|
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
|
|
|
|
export RUSTFLAGS=--cfg=web_sys_unstable_apis
|
2020-11-16 03:55:41 +08:00
|
|
|
|
2018-12-24 02:42:30 +08:00
|
|
|
# Clear output from old stuff:
|
2020-12-29 19:42:15 +08:00
|
|
|
rm -f docs/${CRATE_NAME}_bg.wasm
|
2018-12-24 02:42:30 +08:00
|
|
|
|
2020-12-20 04:30:51 +08:00
|
|
|
echo "Building rust…"
|
|
|
|
BUILD=release
|
2021-01-04 23:31:20 +08:00
|
|
|
cargo build --release --all-features -p ${CRATE_NAME} --lib --target wasm32-unknown-unknown
|
2018-12-24 07:15:18 +08:00
|
|
|
|
2020-12-20 04:30:51 +08:00
|
|
|
echo "Generating JS bindings for wasm…"
|
2020-12-29 19:42:15 +08:00
|
|
|
TARGET_NAME="${CRATE_NAME}.wasm"
|
2019-02-11 03:56:59 +08:00
|
|
|
wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
|
|
|
|
--out-dir docs --no-modules --no-typescript
|
2020-04-23 15:50:03 +08:00
|
|
|
|
2020-12-29 19:42:15 +08:00
|
|
|
echo "Finished: docs/${CRATE_NAME}.wasm"
|
2020-12-20 04:30:51 +08:00
|
|
|
|
2020-11-18 06:24:14 +08:00
|
|
|
open http://localhost:8888/index.html
|