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:
@@ -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
|
||||
|
||||
@@ -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
37
sh/wasm_bindgen_check.sh
Executable 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"
|
||||
Reference in New Issue
Block a user