Change build_demo_web.sh
option from --fast
to --optimize
This commit is contained in:
parent
2500a60062
commit
5d8ef5326b
3 changed files with 19 additions and 15 deletions
|
@ -9,7 +9,7 @@ Run it locally with `cargo run --release -p egui_demo_app`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./sh/start_server.sh &
|
./sh/start_server.sh &
|
||||||
./sh/build_demo_web.sh --fast --open
|
./sh/build_demo_web.sh --open
|
||||||
```
|
```
|
||||||
|
|
||||||
`egui_demo_app` uses [`egui_demo_lib`](https://github.com/emilk/egui/tree/master/egui_demo_lib).
|
`egui_demo_app` uses [`egui_demo_lib`](https://github.com/emilk/egui/tree/master/egui_demo_lib).
|
||||||
|
|
|
@ -3,29 +3,29 @@ 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/.."
|
||||||
|
|
||||||
./sh/setup_web.sh
|
|
||||||
|
|
||||||
CRATE_NAME="egui_demo_app"
|
CRATE_NAME="egui_demo_app"
|
||||||
# NOTE: persistence use up about 400kB (10%) of the WASM!
|
# NOTE: persistence use up about 400kB (10%) of the WASM!
|
||||||
FEATURES="glow,http,persistence,screen_reader"
|
FEATURES="glow,http,persistence,screen_reader"
|
||||||
|
|
||||||
OPEN=false
|
OPEN=false
|
||||||
FAST=false
|
OPTIMIZE=false
|
||||||
|
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
echo "build_demo_web.sh [--fast] [--open]"
|
echo "build_demo_web.sh [--optimize] [--open]"
|
||||||
echo " --fast: skip optimization step"
|
echo ""
|
||||||
echo " --open: open the result in a browser"
|
echo " --optimize: Enable optimization step"
|
||||||
|
echo " Runs wasm-opt."
|
||||||
|
echo " NOTE: --optimize also removes debug symbols which are otherwise useful for in-browser profiling."
|
||||||
|
echo ""
|
||||||
|
echo " --open: Open the result in a browser"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Skip running `wasm-opt`.
|
-O|--optimize)
|
||||||
# --fast also preserves debug symbols, which is great for profiling.
|
|
||||||
--fast)
|
|
||||||
shift
|
shift
|
||||||
FAST=true
|
OPTIMIZE=true
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--open)
|
--open)
|
||||||
|
@ -39,6 +39,8 @@ while test $# -gt 0; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
./sh/setup_web.sh
|
||||||
|
|
||||||
# This is required to enable the web_sys clipboard API which eframe web uses
|
# This is required to enable the web_sys clipboard API which eframe 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
|
||||||
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
|
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
|
||||||
|
@ -74,7 +76,7 @@ wasm-bindgen "${WASM_PATH}" --out-dir docs --no-modules --no-typescript
|
||||||
# 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
|
||||||
|
|
||||||
if [[ "${FAST}" = false ]]; then
|
if [[ "${OPTIMIZE}" = true ]]; then
|
||||||
echo "Optimizing wasm…"
|
echo "Optimizing wasm…"
|
||||||
# to get wasm-opt: apt/brew/dnf install binaryen
|
# 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
|
wasm-opt "docs/${CRATE_NAME}_bg.wasm" -O2 --fast-math -o "docs/${CRATE_NAME}_bg.wasm" # add -g to get debug symbols
|
||||||
|
|
|
@ -6,11 +6,13 @@ cd "$script_path/.."
|
||||||
# Starts a local web-server that serves the contents of the `doc/` folder,
|
# Starts a local web-server that serves the contents of the `doc/` folder,
|
||||||
# i.e. the web-version of `egui_demo_app`.
|
# i.e. the web-version of `egui_demo_app`.
|
||||||
|
|
||||||
|
PORT=8888
|
||||||
|
|
||||||
echo "ensuring basic-http-server is installed…"
|
echo "ensuring basic-http-server is installed…"
|
||||||
cargo install basic-http-server
|
cargo install basic-http-server
|
||||||
|
|
||||||
echo "starting server…"
|
echo "starting server…"
|
||||||
echo "serving at http://localhost:8888"
|
echo "serving at http://localhost:${PORT}"
|
||||||
|
|
||||||
(cd docs && basic-http-server --addr 127.0.0.1:8888 .)
|
(cd docs && basic-http-server --addr 127.0.0.1:${PORT} .)
|
||||||
# (cd docs && python3 -m http.server 8888 --bind 127.0.0.1)
|
# (cd docs && python3 -m http.server ${PORT} --bind 127.0.0.1)
|
||||||
|
|
Loading…
Reference in a new issue