OpenTally/build_wasm.sh

20 lines
650 B
Bash
Raw Normal View History

#!/bin/sh
2021-07-27 22:57:53 +10:00
PATH=$PATH:$HOME/.cargo/bin
# Build cargo
PROFILE=${1:-release}
2021-07-27 22:57:53 +10:00
if [ $PROFILE == 'debug' ]; then
cargo build --lib --target wasm32-unknown-unknown
else
cargo build --lib --target wasm32-unknown-unknown --$PROFILE
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