diff --git a/modules/sqlite/sqlite_worker/build.sh b/modules/sqlite/sqlite_worker/build.sh index 673434f8..9f94bf0e 100755 --- a/modules/sqlite/sqlite_worker/build.sh +++ b/modules/sqlite/sqlite_worker/build.sh @@ -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 +