build_demo_web.sh: add --fast flag to skip optimization step
This commit is contained in:
parent
91bdf9ba6e
commit
0e457c4b06
1 changed files with 33 additions and 7 deletions
|
@ -3,9 +3,33 @@ set -eu
|
||||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||||
cd "$script_path/.."
|
cd "$script_path/.."
|
||||||
|
|
||||||
# Usage: build_demo_web.sh [--open]
|
|
||||||
|
|
||||||
CRATE_NAME="egui_demo_app"
|
CRATE_NAME="egui_demo_app"
|
||||||
|
FEATURES="http,persistence,screen_reader"
|
||||||
|
|
||||||
|
OPEN=false
|
||||||
|
FAST=false
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
echo "build_demo_web.sh [--fast] [--open]"
|
||||||
|
echo " --fast: skip optimization step"
|
||||||
|
echo " --open: open the result in a browser"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--fast)
|
||||||
|
shift
|
||||||
|
FAST=true
|
||||||
|
;;
|
||||||
|
--open)
|
||||||
|
shift
|
||||||
|
OPEN=true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# This is required to enable the web_sys clipboard API which egui_web uses
|
# 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/wasm-bindgen/api/web_sys/struct.Clipboard.html
|
||||||
|
@ -17,7 +41,6 @@ rm -f docs/${CRATE_NAME}_bg.wasm
|
||||||
|
|
||||||
echo "Building rust…"
|
echo "Building rust…"
|
||||||
BUILD=release
|
BUILD=release
|
||||||
FEATURES="http,persistence,screen_reader"
|
|
||||||
|
|
||||||
cargo build \
|
cargo build \
|
||||||
-p ${CRATE_NAME} \
|
-p ${CRATE_NAME} \
|
||||||
|
@ -34,12 +57,15 @@ wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
|
||||||
# to get wasm-strip: apt/brew/dnf install wabt
|
# to get wasm-strip: apt/brew/dnf install wabt
|
||||||
# wasm-strip docs/${CRATE_NAME}_bg.wasm
|
# wasm-strip docs/${CRATE_NAME}_bg.wasm
|
||||||
|
|
||||||
echo "Optimizing wasm…"
|
if [ "${FAST}" = false ]; then
|
||||||
# to get wasm-opt: apt/brew/dnf install binaryen
|
echo "Optimizing wasm…"
|
||||||
wasm-opt docs/${CRATE_NAME}_bg.wasm -O2 --fast-math -o docs/${CRATE_NAME}_bg.wasm # add -g to get debug symbols
|
# to get wasm-opt: apt/brew/dnf install binaryen
|
||||||
|
wasm-opt docs/${CRATE_NAME}_bg.wasm -O2 --fast-math -o docs/${CRATE_NAME}_bg.wasm # add -g to get debug symbols
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Finished docs/${CRATE_NAME}_bg.wasm"
|
echo "Finished docs/${CRATE_NAME}_bg.wasm"
|
||||||
|
|
||||||
if [[ "${1:-}" == "--open" ]]; then
|
if [ "${OPEN}" = true ]; then
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
# Linux, ex: Fedora
|
# Linux, ex: Fedora
|
||||||
xdg-open http://localhost:8888/index.html
|
xdg-open http://localhost:8888/index.html
|
||||||
|
|
Loading…
Reference in a new issue