mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-24 09:06:10 +03:00
41 lines
1.3 KiB
Bash
Executable File
41 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
cd sqlite
|
|
cargo build --release --no-default-features --target wasm32-wasi
|
|
|
|
cd ../sqlite_worker
|
|
|
|
# Get special clang compiler required to build & link sqlite3 C lib.
|
|
mkdir -p target
|
|
cd target
|
|
|
|
WASI_VERSION=20
|
|
WASI_VERSION_FULL=${WASI_VERSION}.0
|
|
CC_PATH=$(realpath ./wasi-sdk-${WASI_VERSION_FULL}/bin/clang)
|
|
|
|
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
|
|
fi
|
|
|
|
CC_PATH=$(realpath ./wasi-sdk-${WASI_VERSION_FULL}/bin/clang)
|
|
|
|
cd ..
|
|
|
|
# We write env vars to `.cargo/config.toml` here because:
|
|
# 1. Doing `export foo=/path && export bar=/path2 && RUSTFLAGS=baz cargo build ...`
|
|
# does not properly pass the RUSTFLAGS (cargo bug?).
|
|
# 2. Specifying `~/path` inside `.cargo/config.toml` doesn't expand.
|
|
mkdir -p .cargo
|
|
|
|
# CC_PATH=$(realpath ~/wasi-sdk/wasi-sdk-20.0/bin/clang)
|
|
|
|
# Write to the .cargo/config.toml file
|
|
cat <<EOF > .cargo/config.toml
|
|
[env]
|
|
CC_wasm32_wasi = "$CC_PATH"
|
|
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
|