2018-12-23 18:42:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
|
2020-12-29 16:54:52 +00:00
|
|
|
CRATE_NAME="egui_demo_app"
|
2018-12-23 18:42:30 +00:00
|
|
|
|
2020-12-29 11:42:15 +00: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-15 19:55:41 +00:00
|
|
|
|
2018-12-23 18:42:30 +00:00
|
|
|
# Clear output from old stuff:
|
2020-12-29 11:42:15 +00:00
|
|
|
rm -f docs/${CRATE_NAME}_bg.wasm
|
2018-12-23 18:42:30 +00:00
|
|
|
|
2020-12-19 20:30:51 +00:00
|
|
|
echo "Building rust…"
|
|
|
|
BUILD=release
|
2021-03-08 19:58:01 +00:00
|
|
|
FEATURES="http,persistence" # screen_reader is experimental
|
|
|
|
# FEATURES="http,persistence,screen_reader" # screen_reader is experimental
|
|
|
|
|
|
|
|
(
|
|
|
|
cd egui_demo_app && cargo build \
|
|
|
|
-p ${CRATE_NAME} \
|
|
|
|
--release \
|
|
|
|
--lib \
|
|
|
|
--target wasm32-unknown-unknown \
|
|
|
|
--features ${FEATURES}
|
|
|
|
)
|
2018-12-23 23:15:18 +00:00
|
|
|
|
2020-12-19 20:30:51 +00:00
|
|
|
echo "Generating JS bindings for wasm…"
|
2020-12-29 11:42:15 +00:00
|
|
|
TARGET_NAME="${CRATE_NAME}.wasm"
|
2019-02-10 19:56:59 +00:00
|
|
|
wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
|
|
|
|
--out-dir docs --no-modules --no-typescript
|
2020-04-23 07:50:03 +00:00
|
|
|
|
2020-12-29 11:42:15 +00:00
|
|
|
echo "Finished: docs/${CRATE_NAME}.wasm"
|
2020-12-19 20:30:51 +00:00
|
|
|
|
2020-11-17 22:24:14 +00:00
|
|
|
open http://localhost:8888/index.html
|