1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

build_demo_web: build debug unless --release is specified

This commit is contained in:
Emil Ernerfeldt
2023-04-20 10:13:57 +02:00
parent f7bba5fba2
commit a27182472f

View File

@@ -3,29 +3,41 @@ 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/.."
./scripts/setup_web.sh
# 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/docs/wasm-bindgen/web-sys/unstable-apis.html
export RUSTFLAGS=--cfg=web_sys_unstable_apis
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,web_screen_reader" FEATURES="glow,http,persistence,web_screen_reader"
OPEN=false OPEN=false
OPTIMIZE=false OPTIMIZE=false
BUILD=debug
BUILD_FLAGS=""
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 [--optimize] [--open]" echo "build_demo_web.sh [--release] [--open]"
echo "" echo ""
echo " --optimize: Enable optimization step" echo " --release: Build with --release, and enable extra optimization step"
echo " Runs wasm-opt." echo " Runs wasm-opt."
echo " NOTE: --optimize also removes debug symbols which are otherwise useful for in-browser profiling." echo " NOTE: --release also removes debug symbols which are otherwise useful for in-browser profiling."
echo "" echo ""
echo " --open: Open the result in a browser" echo " --open: Open the result in a browser"
exit 0 exit 0
;; ;;
-O|--optimize) --release)
shift shift
OPTIMIZE=true OPTIMIZE=true
BUILD="release"
BUILD_FLAGS="--release"
;; ;;
--open) --open)
@@ -39,22 +51,14 @@ while test $# -gt 0; do
esac esac
done done
./scripts/setup_web.sh
# 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/docs/wasm-bindgen/web-sys/unstable-apis.html
export RUSTFLAGS=--cfg=web_sys_unstable_apis
# Clear output from old stuff: # Clear output from old stuff:
rm -f "docs/${CRATE_NAME}_bg.wasm" rm -f "docs/${CRATE_NAME}_bg.wasm"
echo "Building rust…" echo "Building rust…"
BUILD=release
(cd crates/$CRATE_NAME && (cd crates/$CRATE_NAME &&
cargo build \ cargo build \
--release \ ${BUILD_FLAGS} \
--lib \ --lib \
--target wasm32-unknown-unknown \ --target wasm32-unknown-unknown \
--no-default-features \ --no-default-features \