build_demo_web.sh: add --open as an option
This commit is contained in:
parent
6b24dbc997
commit
f38f68318d
1 changed files with 19 additions and 17 deletions
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
# Usage: build_demo_web.sh [--open]
|
||||||
|
|
||||||
CRATE_NAME="egui_demo_app"
|
CRATE_NAME="egui_demo_app"
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -15,14 +17,12 @@ echo "Building rust…"
|
||||||
BUILD=release
|
BUILD=release
|
||||||
FEATURES="http,persistence,screen_reader"
|
FEATURES="http,persistence,screen_reader"
|
||||||
|
|
||||||
(
|
cargo build \
|
||||||
cd egui_demo_app && cargo build \
|
|
||||||
-p ${CRATE_NAME} \
|
-p ${CRATE_NAME} \
|
||||||
--release \
|
--release \
|
||||||
--lib \
|
--lib \
|
||||||
--target wasm32-unknown-unknown \
|
--target wasm32-unknown-unknown \
|
||||||
--features ${FEATURES}
|
--features ${FEATURES}
|
||||||
)
|
|
||||||
|
|
||||||
echo "Generating JS bindings for wasm…"
|
echo "Generating JS bindings for wasm…"
|
||||||
TARGET_NAME="${CRATE_NAME}.wasm"
|
TARGET_NAME="${CRATE_NAME}.wasm"
|
||||||
|
@ -37,6 +37,7 @@ 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
|
wasm-opt docs/${CRATE_NAME}_bg.wasm -O2 --fast-math -o docs/${CRATE_NAME}_bg.wasm # add -g to get debug symbols
|
||||||
echo "Finished docs/${CRATE_NAME}_bg.wasm"
|
echo "Finished docs/${CRATE_NAME}_bg.wasm"
|
||||||
|
|
||||||
|
if [[ "${1:-}" == "--open" ]]; 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
|
||||||
|
@ -47,3 +48,4 @@ else
|
||||||
# Darwin/MacOS, or something else
|
# Darwin/MacOS, or something else
|
||||||
open http://localhost:8888/index.html
|
open http://localhost:8888/index.html
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue