veilid/veilid-wasm/wasm_build.sh

26 lines
1007 B
Bash
Raw Normal View History

2022-03-15 09:33:34 -04:00
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2022-03-17 10:31:10 -04:00
pushd $SCRIPTDIR &> /dev/null
2022-03-17 19:03:42 -04:00
if [[ "$1" == "debug" ]]; then
2022-03-17 10:31:10 -04:00
OUTPUTDIR=../target/wasm32-unknown-unknown/debug/pkg
INPUTDIR=../target/wasm32-unknown-unknown/debug
RUSTFLAGS="-O -g" cargo build --target wasm32-unknown-unknown
mkdir -p $OUTPUTDIR
wasm-bindgen --out-dir $OUTPUTDIR --target web --no-typescript --keep-debug --debug $INPUTDIR/veilid_wasm.wasm
./wasm-sourcemap.py $OUTPUTDIR/veilid_wasm_bg.wasm -o $OUTPUTDIR/veilid_wasm_bg.wasm.map --dwarfdump `which llvm-dwarfdump`
wasm-strip $OUTPUTDIR/veilid_wasm_bg.wasm
2022-03-17 19:03:42 -04:00
else
OUTPUTDIR=../target/wasm32-unknown-unknown/release/pkg
INPUTDIR=../target/wasm32-unknown-unknown/release
cargo build --target wasm32-unknown-unknown --release
mkdir -p $OUTPUTDIR
wasm-bindgen --out-dir $OUTPUTDIR --target web --no-typescript $INPUTDIR/veilid_wasm.wasm
wasm-strip $OUTPUTDIR/veilid_wasm_bg.wasm
2022-03-15 09:33:34 -04:00
fi
2022-03-17 10:31:10 -04:00
popd &> /dev/null