From c1ccf545011c9d1603838d7187f2864e1c916d34 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sat, 11 Sep 2021 21:12:51 +1000 Subject: [PATCH] Don't reapply wasm-bindgen/wasm-opt if no changes --- build_wasm.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/build_wasm.sh b/build_wasm.sh index 02ffaa5..132812c 100755 --- a/build_wasm.sh +++ b/build_wasm.sh @@ -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