Don't reapply wasm-bindgen/wasm-opt if no changes

This commit is contained in:
RunasSudo 2021-09-11 21:12:51 +10:00
parent df1b2f7bdc
commit c1ccf54501
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 10 additions and 8 deletions

View File

@ -9,11 +9,13 @@ else
cargo build --lib --target wasm32-unknown-unknown --$PROFILE || exit 1
fi
# Apply wasm-bindgen
wasm-bindgen --target no-modules target/wasm32-unknown-unknown/$PROFILE/opentally.wasm --out-dir html --no-typescript
# Apply Asyncify
MANGLED=$(wasm-dis html/opentally_bg.wasm | grep '(import "wbg" "__wbg_getuserinput_' | awk '{print $3;}' | tr -d '"')
wasm-opt -O2 --asyncify --pass-arg asyncify-imports@wbg.$MANGLED html/opentally_bg.wasm -o html/opentally_async.wasm
rm html/opentally_bg.wasm
if [ target/wasm32-unknown-unknown/$PROFILE/opentally.wasm -nt html/opentally_async.wasm ]; then
# Apply wasm-bindgen
wasm-bindgen --target no-modules target/wasm32-unknown-unknown/$PROFILE/opentally.wasm --out-dir html --no-typescript
# Apply Asyncify
MANGLED=$(wasm-dis html/opentally_bg.wasm | grep '(import "wbg" "__wbg_getuserinput_' | awk '{print $3;}' | tr -d '"')
wasm-opt -O2 --asyncify --pass-arg asyncify-imports@wbg.$MANGLED html/opentally_bg.wasm -o html/opentally_async.wasm
rm html/opentally_bg.wasm
fi