egui/sh/wasm_bindgen_check.sh
Emil Ernerfeldt 931e716b97
Add egui_wgpu crate (#1564)
Based on https://github.com/hasenbanck/egui_wgpu_backend

`egui-wgpu` is now an official backend for `eframe` (opt-in).

Use the `wgpu` feature flag on `eframe` and the `NativeOptions::renderer` settings to pick it.

Co-authored-by: Nils Hasenbanck <nils@hasenbanck.de>
Co-authored-by: Sven Niederberger <niederberger@embotech.com>
Co-authored-by: Sven Niederberger <73159570+s-nie@users.noreply.github.com>
2022-05-12 09:02:28 +02:00

37 lines
1,005 B
Bash
Executable file

#!/usr/bin/env bash
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
CRATE_NAME="egui_demo_app"
FEATURES="glow,http,persistence,screen_reader"
# 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
echo "Building rust…"
BUILD=debug # debug builds are faster
(cd $CRATE_NAME &&
cargo build \
--lib \
--target wasm32-unknown-unknown \
--no-default-features \
--features ${FEATURES}
)
TARGET="target"
echo "Generating JS bindings for wasm…"
rm -f "${CRATE_NAME}_bg.wasm" # Remove old output (if any)
TARGET_NAME="${CRATE_NAME}.wasm"
wasm-bindgen "${TARGET}/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
--out-dir . --no-modules --no-typescript
# Remove output:
rm -f "${CRATE_NAME}_bg.wasm"
rm -f "${CRATE_NAME}.js"