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:
parent
2e1a4cf08a
commit
c5a9421dbd
7 changed files with 103 additions and 10 deletions
14
.github/workflows/rust.yml
vendored
14
.github/workflows/rust.yml
vendored
|
@ -153,3 +153,17 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: EmbarkStudios/cargo-deny-action@v1
|
- uses: EmbarkStudios/cargo-deny-action@v1
|
||||||
|
|
||||||
|
wasm_bindgen:
|
||||||
|
name: wasm-bindgen
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: 1.56.0
|
||||||
|
override: true
|
||||||
|
- run: rustup target add wasm32-unknown-unknown
|
||||||
|
- run: cargo install wasm-bindgen-cli
|
||||||
|
- run: ./sh/wasm_bindgen_check.sh
|
||||||
|
|
46
Cargo.lock
generated
46
Cargo.lock
generated
|
@ -1060,7 +1060,7 @@ version = "0.16.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"egui",
|
"egui",
|
||||||
"image",
|
"image",
|
||||||
"parking_lot",
|
"parking_lot 0.12.0",
|
||||||
"resvg",
|
"resvg",
|
||||||
"tiny-skia",
|
"tiny-skia",
|
||||||
"usvg",
|
"usvg",
|
||||||
|
@ -1209,7 +1209,7 @@ dependencies = [
|
||||||
"criterion",
|
"criterion",
|
||||||
"emath",
|
"emath",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"parking_lot",
|
"parking_lot 0.12.0",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1517,7 +1517,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"objc",
|
"objc",
|
||||||
"osmesa-sys",
|
"osmesa-sys",
|
||||||
"parking_lot",
|
"parking_lot 0.11.2",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
"wayland-egl",
|
"wayland-egl",
|
||||||
"winapi",
|
"winapi",
|
||||||
|
@ -2287,7 +2287,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"instant",
|
"instant",
|
||||||
"lock_api",
|
"lock_api",
|
||||||
"parking_lot_core",
|
"parking_lot_core 0.8.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58"
|
||||||
|
dependencies = [
|
||||||
|
"lock_api",
|
||||||
|
"parking_lot_core 0.9.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2304,6 +2314,19 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot_core"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"smallvec",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "peeking_take_while"
|
name = "peeking_take_while"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
|
@ -3713,6 +3736,19 @@ dependencies = [
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.32.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_msvc",
|
||||||
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.32.0"
|
version = "0.32.0"
|
||||||
|
@ -3764,7 +3800,7 @@ dependencies = [
|
||||||
"ndk-glue 0.5.1",
|
"ndk-glue 0.5.1",
|
||||||
"ndk-sys 0.2.2",
|
"ndk-sys 0.2.2",
|
||||||
"objc",
|
"objc",
|
||||||
"parking_lot",
|
"parking_lot 0.11.2",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"smithay-client-toolkit",
|
"smithay-client-toolkit",
|
||||||
|
|
|
@ -33,7 +33,7 @@ svg = ["resvg", "tiny-skia", "usvg"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui = { version = "0.16.1", path = "../egui", default-features = false, features = ["single_threaded"] }
|
egui = { version = "0.16.1", path = "../egui", default-features = false, features = ["single_threaded"] }
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.12"
|
||||||
|
|
||||||
# Optional dependencies:
|
# Optional dependencies:
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ atomic_refcell = { version = "0.1", optional = true } # Used instead of parking_
|
||||||
bytemuck = { version = "1.7.2", features = ["derive"], optional = true }
|
bytemuck = { version = "1.7.2", features = ["derive"], optional = true }
|
||||||
cint = { version = "^0.2.2", optional = true }
|
cint = { version = "^0.2.2", optional = true }
|
||||||
nohash-hasher = "0.2"
|
nohash-hasher = "0.2"
|
||||||
parking_lot = { version = "0.11", optional = true } # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios.
|
parking_lot = { version = "0.12", optional = true } # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios.
|
||||||
serde = { version = "1", features = ["derive", "rc"], optional = true }
|
serde = { version = "1", features = ["derive", "rc"], optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -56,8 +56,12 @@ TARGET=`cargo metadata --format-version=1 | jq --raw-output .target_directory`
|
||||||
|
|
||||||
echo "Generating JS bindings for wasm…"
|
echo "Generating JS bindings for wasm…"
|
||||||
TARGET_NAME="${CRATE_NAME}.wasm"
|
TARGET_NAME="${CRATE_NAME}.wasm"
|
||||||
wasm-bindgen "${TARGET}/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
|
WASM_PATH="${TARGET}/wasm32-unknown-unknown/$BUILD/$TARGET_NAME"
|
||||||
--out-dir docs --no-modules --no-typescript
|
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
|
# to get wasm-strip: apt/brew/dnf install wabt
|
||||||
# wasm-strip docs/${CRATE_NAME}_bg.wasm
|
# 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 epaint && cargo check --all-features)
|
||||||
(cd epi && cargo check --all-features)
|
(cd epi && cargo check --all-features)
|
||||||
|
|
||||||
|
./sh/wasm_bindgen_check.sh --fast
|
||||||
|
|
||||||
# cargo install cargo-deny
|
# 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"
|
Loading…
Reference in a new issue