branch on linux/mac wasi-sdk (#37)

This commit is contained in:
bitful-pannul 2023-10-25 14:50:46 +02:00 committed by GitHub
parent d1c607f388
commit d8c10db602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,9 +13,20 @@ WASI_VERSION=20
WASI_VERSION_FULL=${WASI_VERSION}.0
CC_PATH=$(realpath ./wasi-sdk-${WASI_VERSION_FULL}/bin/clang)
# Determine operating system
OS_TYPE="$(uname)"
if [ "$OS_TYPE" = "Darwin" ]; then
WASI_PLATFORM="macos"
elif [ "$OS_TYPE" = "Linux" ]; then
WASI_PLATFORM="linux"
else
echo "Unsupported OS: $OS_TYPE"
exit 1
fi
if [ ! -e "$CC_PATH" ]; then
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
tar xvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-${WASI_PLATFORM}.tar.gz
tar xvf wasi-sdk-${WASI_VERSION_FULL}-${WASI_PLATFORM}.tar.gz
fi
CC_PATH=$(realpath ./wasi-sdk-${WASI_VERSION_FULL}/bin/clang)
@ -38,3 +49,4 @@ CARGO_TARGET_WASM32_WASI_LINKER = "$CC_PATH"
EOF
RUSTFLAGS="-C target-feature=-crt-static -C link-arg=-Wl,--no-entry,--export=init,--export=cabi_realloc" cargo build --release --no-default-features --target wasm32-wasi