2022-03-15 13:33:34 +00:00
|
|
|
#!/bin/bash
|
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
|
2022-12-25 16:46:32 +00:00
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
get_abs_filename() {
|
|
|
|
# $1 : relative filename
|
|
|
|
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
|
|
|
}
|
|
|
|
|
2022-03-17 14:31:10 +00:00
|
|
|
pushd $SCRIPTDIR &> /dev/null
|
|
|
|
|
2022-06-16 03:29:45 +00:00
|
|
|
if [ -f /usr/local/opt/llvm/bin/llvm-dwarfdump ]; then
|
|
|
|
DWARFDUMP=/usr/local/opt/llvm/bin/llvm-dwarfdump
|
|
|
|
elif [ -f /opt/homebrew/llvm/bin/llvm-dwarfdump ]; then
|
|
|
|
DWARFDUMP=/opt/homebrew/llvm/bin/llvm-dwarfdump
|
|
|
|
else
|
|
|
|
DWARFDUMP=`which llvm-dwarfdump`
|
|
|
|
if [[ "${DWARFDUMP}" == "" ]]; then
|
|
|
|
echo llvm-dwarfdump not found
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2022-12-25 16:46:32 +00:00
|
|
|
if [[ "$1" == "release" ]]; then
|
|
|
|
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
|
|
|
|
else
|
2022-03-17 14:31:10 +00: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
|
2022-06-16 03:29:45 +00:00
|
|
|
./wasm-sourcemap.py $OUTPUTDIR/veilid_wasm_bg.wasm -o $OUTPUTDIR/veilid_wasm_bg.wasm.map --dwarfdump $DWARFDUMP
|
2022-06-30 02:17:19 +00:00
|
|
|
# wasm-strip $OUTPUTDIR/veilid_wasm_bg.wasm
|
2022-03-15 13:33:34 +00:00
|
|
|
fi
|
|
|
|
|
2022-03-17 14:31:10 +00:00
|
|
|
popd &> /dev/null
|
2022-12-25 16:46:32 +00:00
|
|
|
|
|
|
|
# Print for use with scripts
|
|
|
|
echo SUCCESS:OUTPUTDIR=$(get_abs_filename $OUTPUTDIR)
|