-
Notifications
You must be signed in to change notification settings - Fork 16
/
install-wasi-sdk.sh
executable file
·34 lines (30 loc) · 1.21 KB
/
install-wasi-sdk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
#set -euo pipefail
if [[ "$(basename $(pwd))" != "js-pdk" ]]; then
echo "Run this inside in the root of the js-pdk repo" 1>&2
exit 1
fi
# Don't try and install the wasi-sdk if the user has specified the wasi-sdk is installed elsewhere
set +u
if [[ -n "$QUICKJS_WASM_SYS_WASI_SDK_PATH" ]]; then
# Check that something is present where the user says the wasi-sdk is located
if [[ ! -d "$QUICKJS_WASM_SYS_WASI_SDK_PATH" ]]; then
echo "Download the wasi-sdk to $QUICKJS_WASM_SYS_WASI_SDK_PATH" 1>&2
exit 1
fi
exit 0
fi
set -u
PATH_TO_SDK="wasi-sdk"
if [[ ! -d $PATH_TO_SDK ]]; then
TMPGZ=$(mktemp)
VERSION_MAJOR="12"
VERSION_MINOR="0"
if [[ "$(uname -s)" == "Darwin" ]]; then
curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-macos.tar.gz --output $TMPGZ
else
curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-linux.tar.gz --output $TMPGZ
fi
mkdir $PATH_TO_SDK
tar xf $TMPGZ -C $PATH_TO_SDK --strip-components=1
fi