!/usr/bin/env bash emcc_exists=β$(command -v emcc)β if [ ! β${emcc_exists}β ]; then
echo "Emscripten not on path" exit 1
fi
set -e
cd β$1β shift
# Parse arguments while [ $# -gt 0 ]; do
case $1 in --wasm-bigint) WASM_BIGINT=true ;; *) echo "ERROR: Unknown parameter: $1" >&2 exit 1 ;; esac shift
done
export CFLAGS=β-fPIC -O2 -I../../target/include $EXTRA_CFLAGSβ export CXXFLAGS=β$CFLAGS -sNO_DISABLE_EXCEPTION_CATCHING $EXTRA_CXXFLAGSβ export LDFLAGS=β \
-L../../target/lib/ -lffi \ -sEXPORT_ALL \ -sMODULARIZE \ -sMAIN_MODULE \ -sNO_DISABLE_EXCEPTION_CATCHING \ $EXTRA_LD_FLAGS \
β
# This needs to test false if there exists an environment variable called # WASM_BIGINT whose contents are empty. Donβt use +x. if [ -n β${WASM_BIGINT}β ] ; then
export LDFLAGS+=" -sWASM_BIGINT"
else
export LDFLAGS+=" -sEXPORTED_RUNTIME_METHODS='getTempRet0,setTempRet0'"
fi
# Rename main functions to test__filename so we can link them together ls *c | sed βs!(.*).c!sed -i βs/main/test__1/gβ 0!gβ | bash
# Compile ls *.c | sed βs/(.*).c/emcc $CFLAGS -c 1.c -o 1.o /gβ | bash ls *.cc | sed βs/(.*).cc/em++ $CXXFLAGS -c 1.cc -o 1.o /gβ | bash
# Link em++ $LDFLAGS *.o -o test.js cp ../emscripten/test.html .