1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00
Files
egui/build_demo_web.sh
Cristian Dinu b3aa4982f6 Adapt the URL open command to the platform
With this new version we use $OSTYPE bash env var to query what OS
are we running on.

- On Linux, ex: Fedora, we use `xdg-open`
- On Windows, ex: msys, we use `start`
- For other other variants we try to use `open`

We should update this script when we notice that `open` is not
available on a particular platform.
2021-03-24 13:22:09 +02:00

45 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -eu
CRATE_NAME="egui_demo_app"
# This is required to enable the web_sys clipboard API which egui_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:
rm -f docs/${CRATE_NAME}_bg.wasm
echo "Building rust…"
BUILD=release
FEATURES="http,persistence" # screen_reader is experimental
# FEATURES="http,persistence,screen_reader" # screen_reader is experimental
(
cd egui_demo_app && cargo build \
-p ${CRATE_NAME} \
--release \
--lib \
--target wasm32-unknown-unknown \
--features ${FEATURES}
)
echo "Generating JS bindings for wasm…"
TARGET_NAME="${CRATE_NAME}.wasm"
wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
--out-dir docs --no-modules --no-typescript
echo "Finished: docs/${CRATE_NAME}.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
# Darmin aka MacOS or something else
open http://localhost:8888/index.html
fi