Add -g option to build_demo_web.sh
This commit is contained in:
parent
d978b37732
commit
790b401adf
|
|
@ -19,23 +19,37 @@ OPTIMIZE=false
|
||||||
BUILD=debug
|
BUILD=debug
|
||||||
BUILD_FLAGS=""
|
BUILD_FLAGS=""
|
||||||
WEB_GPU=false
|
WEB_GPU=false
|
||||||
|
WASM_OPT_FLAGS="-O2 --fast-math"
|
||||||
|
|
||||||
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 [--release] [--webgpu] [--open]"
|
echo "build_demo_web.sh [--release] [--webgpu] [--open]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " --release: Build with --release, and enable extra optimization step"
|
echo " -g: Keep debug symbols even with --release."
|
||||||
echo " Runs wasm-opt."
|
echo " These are useful profiling and size trimming."
|
||||||
echo " NOTE: --release also removes debug symbols which are otherwise useful for in-browser profiling."
|
|
||||||
echo ""
|
echo ""
|
||||||
echo " --webgpu: Build a binary for WebGPU instead of WebGL"
|
echo " --open: Open the result in a browser."
|
||||||
|
echo ""
|
||||||
|
echo " --release: Build with --release, and then run wasm-opt."
|
||||||
|
echo " NOTE: --release also removes debug symbols, unless you also use -g."
|
||||||
|
echo ""
|
||||||
|
echo " --webgpu: Build a binary for WebGPU instead of WebGL."
|
||||||
echo " Note that the resulting wasm will ONLY work on browsers with WebGPU."
|
echo " Note that the resulting wasm will ONLY work on browsers with WebGPU."
|
||||||
echo ""
|
|
||||||
echo " --open: Open the result in a browser"
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
-g)
|
||||||
|
shift
|
||||||
|
WASM_OPT_FLAGS="${WASM_OPT_FLAGS} -g"
|
||||||
|
echo "'${WASM_OPT_FLAGS}'"
|
||||||
|
;;
|
||||||
|
|
||||||
|
--open)
|
||||||
|
shift
|
||||||
|
OPEN=true
|
||||||
|
;;
|
||||||
|
|
||||||
--release)
|
--release)
|
||||||
shift
|
shift
|
||||||
OPTIMIZE=true
|
OPTIMIZE=true
|
||||||
|
|
@ -48,11 +62,6 @@ while test $# -gt 0; do
|
||||||
WEB_GPU=true
|
WEB_GPU=true
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--open)
|
|
||||||
shift
|
|
||||||
OPEN=true
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Unknown option: $1"
|
echo "Unknown option: $1"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -96,6 +105,7 @@ wasm-bindgen "${WASM_PATH}" --out-dir web_demo --out-name ${OUT_FILE_NAME} --no-
|
||||||
# if this fails with "error: cannot import from modules (`env`) with `--no-modules`", you can use:
|
# if this fails with "error: cannot import from modules (`env`) with `--no-modules`", you can use:
|
||||||
# wasm2wat target/wasm32-unknown-unknown/release/egui_demo_app.wasm | rg env
|
# wasm2wat target/wasm32-unknown-unknown/release/egui_demo_app.wasm | rg env
|
||||||
# wasm2wat target/wasm32-unknown-unknown/release/egui_demo_app.wasm | rg "call .now\b" -B 20 # What calls `$now` (often a culprit)
|
# wasm2wat target/wasm32-unknown-unknown/release/egui_demo_app.wasm | rg "call .now\b" -B 20 # What calls `$now` (often a culprit)
|
||||||
|
# Or use https://rustwasm.github.io/twiggy/usage/command-line-interface/paths.html#twiggy-paths
|
||||||
|
|
||||||
# to get wasm-strip: apt/brew/dnf install wabt
|
# to get wasm-strip: apt/brew/dnf install wabt
|
||||||
# wasm-strip ${FINAL_WASM_PATH}
|
# wasm-strip ${FINAL_WASM_PATH}
|
||||||
|
|
@ -103,7 +113,7 @@ wasm-bindgen "${WASM_PATH}" --out-dir web_demo --out-name ${OUT_FILE_NAME} --no-
|
||||||
if [[ "${OPTIMIZE}" = true ]]; 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 "${FINAL_WASM_PATH}" -O2 --fast-math -o "${FINAL_WASM_PATH}" # add -g to get debug symbols
|
wasm-opt "${FINAL_WASM_PATH}" $WASM_OPT_FLAGS -o "${FINAL_WASM_PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Finished ${FINAL_WASM_PATH}"
|
echo "Finished ${FINAL_WASM_PATH}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue