From f38f68318d0860f268f757699afcf067d6d291a7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 24 Apr 2021 09:41:57 +0200 Subject: [PATCH] build_demo_web.sh: add --open as an option --- build_demo_web.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/build_demo_web.sh b/build_demo_web.sh index de604ef7..c148fc2b 100755 --- a/build_demo_web.sh +++ b/build_demo_web.sh @@ -1,6 +1,8 @@ #!/bin/bash set -eu +# Usage: build_demo_web.sh [--open] + CRATE_NAME="egui_demo_app" # This is required to enable the web_sys clipboard API which egui_web uses @@ -15,14 +17,12 @@ echo "Building rust…" BUILD=release FEATURES="http,persistence,screen_reader" -( - cd egui_demo_app && cargo build \ - -p ${CRATE_NAME} \ - --release \ - --lib \ - --target wasm32-unknown-unknown \ - --features ${FEATURES} -) +cargo build \ + -p ${CRATE_NAME} \ + --release \ + --lib \ + --target wasm32-unknown-unknown \ + --features ${FEATURES} echo "Generating JS bindings for wasm…" TARGET_NAME="${CRATE_NAME}.wasm" @@ -37,13 +37,15 @@ 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 echo "Finished docs/${CRATE_NAME}_bg.wasm" -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - # Linux, ex: Fedora - xdg-open http://localhost:8888/index.html -elif [[ "$OSTYPE" == "msys" ]]; then - # Windows - start http://localhost:8888/index.html -else - # Darwin/MacOS, or something else - open http://localhost:8888/index.html +if [[ "${1:-}" == "--open" ]]; then + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Linux, ex: Fedora + xdg-open http://localhost:8888/index.html + elif [[ "$OSTYPE" == "msys" ]]; then + # Windows + start http://localhost:8888/index.html + else + # Darwin/MacOS, or something else + open http://localhost:8888/index.html + fi fi