Add second optional arg support.

This commit is contained in:
Jacques Wagener 2019-10-04 15:10:30 +02:00
parent 7456da9d64
commit 881eb3452b
No known key found for this signature in database
GPG Key ID: C294D1025DA0E923
1 changed files with 16 additions and 3 deletions

View File

@ -1,18 +1,31 @@
#!/bin/bash
# For use inside Nimplay Docker image.
NIM_FILE=$1
if [[ $# -eq 2 ]];
then
WASM_FILE="$2"
else
WASM_FILE="${NIM_FILE%.*}.wasm"
fi
PANIC_PATH="$(dirname ${NIM_FILE})"
set -ex
PATH_PARAMS="-p:/nimplay/ -p:/nimplay/vendor/nimcrypto -p:/nimplay/vendor/stint -p:/nimplay/vendor/nim-stew/"
NIM_CLANG_C_FLAGS="--passC:\""--target=wasm32-unknown-unknown-wasm\"" --passC:\""-I./include\"""
NIM_CLANG_LINKER_FLAGS="--clang.options.linker:\"-nostdlib -Wl,--no-entry,--allow-undefined,--strip-all,--export-dynamic\" --passL:\"--target=wasm32-unknown-unknown-wasm\""
NIM_CLANG_ALL_FLAGS="${NIM_CLANG_C_FLAGS} ${NIM_CLANG_LINKER_FLAGS} --os:standalone --cpu:i386 --cc:clang --gc:none --nomain -d:release"
NIM_CLANG_WASM32_C="nim c -d:osk256_sig ${PATH_PARAMS} ${NIM_CLANG_ALL_FLAGS}"
FULL_CMD="${NIM_CLANG_WASM32_C} --out:${WASM_FILE} ${NIM_FILE}"
cp /nimplay/examples/panicoverride.nim $PANIC_PATH/
eval "${NIM_CLANG_WASM32_C} --out:${WASM_FILE} ${NIM_FILE}"
echo $FULL_CMD
eval $FULL_CMD
if [ $? -ne 0 ]; then
rm $PANIC_PATH/panicoverride.nim
exit 1
fi
# Postprocess produced wasm file
wasm2wat="wasm2wat"