1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Run wasm-bindgen in CI and update parking_lot (#1293)

* Run wasm-bindgen in CI
* Update parking_lot 0.11 -> 0.12
This commit is contained in:
Emil Ernerfeldt
2022-02-22 16:30:42 +01:00
committed by GitHub
parent 2e1a4cf08a
commit c5a9421dbd
7 changed files with 103 additions and 10 deletions

View File

@@ -56,8 +56,12 @@ TARGET=`cargo metadata --format-version=1 | jq --raw-output .target_directory`
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
WASM_PATH="${TARGET}/wasm32-unknown-unknown/$BUILD/$TARGET_NAME"
wasm-bindgen ${WASM_PATH} --out-dir docs --no-modules --no-typescript
# 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 "call .now\b" -B 20 # What calls `$now` (often a culprit)
# to get wasm-strip: apt/brew/dnf install wabt
# wasm-strip docs/${CRATE_NAME}_bg.wasm

View File

@@ -46,8 +46,10 @@ cargo doc --document-private-items --no-deps --all-features
(cd epaint && cargo check --all-features)
(cd epi && cargo check --all-features)
./sh/wasm_bindgen_check.sh --fast
# cargo install cargo-deny
# cargo deny check
cargo deny check
# ------------------------------------------------------------
#

37
sh/wasm_bindgen_check.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
CRATE_NAME="egui_demo_app"
FEATURES="http,persistence,screen_reader"
# 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
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"