Open-source election counting https://yingtongli.me/opentally/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
OpenTally/scripts/build_wasm.sh

21 lines
778 B

#!/bin/sh
PATH=$PATH:$HOME/.cargo/bin
# Build cargo
PROFILE=${1:-release}
if [ $PROFILE == 'debug' ]; then
cargo build --lib --target wasm32-unknown-unknown || exit 1
else
cargo build --lib --target wasm32-unknown-unknown --$PROFILE || exit 1
fi
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