2023-10-25 02:32:01 +08:00
|
|
|
#!/usr/bin/env bash
|
2023-03-14 07:51:32 +08:00
|
|
|
|
|
|
|
# Add wasm32 target for compiler.
|
|
|
|
rustup target add wasm32-unknown-unknown
|
|
|
|
|
|
|
|
if ! command -v wasm-pack &> /dev/null
|
|
|
|
then
|
|
|
|
echo "wasm-pack could not be found. Installing ..."
|
|
|
|
cargo install wasm-pack
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set optimization flags
|
2024-08-08 01:59:53 +08:00
|
|
|
export RUSTFLAGS="-C embed-bitcode=yes -C codegen-units=1 -C opt-level=3 --cfg web_sys_unstable_apis"
|
2023-03-14 07:51:32 +08:00
|
|
|
|
|
|
|
# Run wasm pack tool to build JS wrapper files and copy wasm to pkg directory.
|
2023-03-14 08:13:39 +08:00
|
|
|
mkdir -p pkg
|
2023-09-29 05:09:58 +08:00
|
|
|
wasm-pack build --out-dir pkg --release --target web --no-typescript --no-default-features --features $1
|
2023-03-14 07:51:32 +08:00
|
|
|
|