2021-06-01 11:04:03 +02:00
|
|
|
#!/bin/sh
|
2021-07-27 14:57:53 +02:00
|
|
|
PATH=$PATH:$HOME/.cargo/bin
|
|
|
|
|
|
|
|
# Build cargo
|
2021-06-13 08:34:27 +02:00
|
|
|
PROFILE=${1:-release}
|
2021-07-27 14:57:53 +02:00
|
|
|
if [ $PROFILE == 'debug' ]; then
|
2021-07-31 07:24:23 +02:00
|
|
|
cargo build --lib --target wasm32-unknown-unknown || exit 1
|
2021-07-27 14:57:53 +02:00
|
|
|
else
|
2021-07-31 07:24:23 +02:00
|
|
|
cargo build --lib --target wasm32-unknown-unknown --$PROFILE || exit 1
|
2021-07-27 14:57:53 +02:00
|
|
|
fi
|
|
|
|
|
2021-09-11 13:12:51 +02:00
|
|
|
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
|