mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
62 lines
1.5 KiB
Bash
Executable File
62 lines
1.5 KiB
Bash
Executable File
#! /bin/sh
|
|
|
|
MAX_MEMORY_TESTS="67108864"
|
|
|
|
unset LDFLAGS
|
|
unset CFLAGS
|
|
|
|
if command -v wasm-opt >/dev/null; then
|
|
wasm-opt -O4 -o "${1}.tmp" "$1" && mv -f "${1}.tmp" "$1"
|
|
fi
|
|
|
|
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wavm" ]; then
|
|
if command -v wavm >/dev/null; then
|
|
wavm run --abi=wasi "$1" && exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmtime" ]; then
|
|
if command -v wasmtime >/dev/null; then
|
|
wasmtime run --dir=. "$1" && exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmer" ]; then
|
|
if command -v wasmer >/dev/null; then
|
|
wasmer run "$1" "--${WASMER_BACKEND:-cranelift}" --dir=. && exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmer-js" ]; then
|
|
if command -v wasmer-js >/dev/null; then
|
|
wasmer-js run "$1" --dir=. && exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasm3" ]; then
|
|
if command -v wasm3 >/dev/null; then
|
|
wasm3 "$1" && exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "iwasm" ]; then
|
|
if iwasm | grep -qi wasi >/dev/null 2>&1; then
|
|
iwasm "$1" && exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "lucet" ]; then
|
|
if command -v lucetc-wasi >/dev/null && command -v lucet-wasi >/dev/null; then
|
|
lucetc-wasi \
|
|
--target-cpu native \
|
|
--reserved-size "${MAX_MEMORY_TESTS}" \
|
|
--opt-level speed \
|
|
"$1" -o "${1}.so" &&
|
|
lucet-wasi --dir=.:. --max-heap-size "${MAX_MEMORY_TESTS}" "${1}.so" &&
|
|
rm -f "${1}.so" && exit 0
|
|
fi
|
|
fi
|
|
|
|
echo "WebAssembly runtime failed" >&2
|
|
exit 1
|