1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 18:45:32 -07:00
libsodium/test/default/wasi-test-wrapper.sh

27 lines
735 B
Bash
Raw Normal View History

2019-04-08 12:45:08 -07:00
#! /bin/sh
2019-04-22 16:23:41 -07:00
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmtime" ]; then
if command -v wasmtime >/dev/null; then
wasmtime -o --dir=. "$1" && exit 0
fi
fi
2019-04-22 16:24:12 -07:00
2019-04-22 16:23:41 -07:00
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmer" ]; then
if command -v wasmer >/dev/null; then
wasmer run "$1" --backend "${WASMER_BACKEND:-cranelift}" --dir=. && exit 0
fi
fi
2019-04-22 16:24:12 -07:00
2019-04-22 16:23:41 -07:00
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "lucet" ]; then
if command -v lucetc-wasi >/dev/null && command -v lucet-wasi >/dev/null; then
lucetc-wasi \
--min-reserved-size "128MiB" \
-o "${1}.so" --opt-level best "$1" &&
2019-04-22 17:01:49 -07:00
lucet-wasi --dir=.:. "${1}.so" &&
rm -f "${1}.so" && exit 0
2019-04-22 16:23:41 -07:00
fi
fi
2019-04-22 16:24:12 -07:00
2019-04-22 16:23:41 -07:00
echo "WebAssembly runtime failed" >&2
exit 1