-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild-wasm-examples.sh
executable file
·29 lines (18 loc) · 1.08 KB
/
build-wasm-examples.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
#!/bin/bash
# This script builds, optimizes and packages all the examples as WASM demos
set -ex
EXAMPLES=(
"miner"
"cells"
# "resman"
# "von_neumann"
)
for EXAMPLE in "${EXAMPLES[@]}"; do
RUSTFLAGS="-Zlocation-detail=none" cargo build --profile=wasm-release --no-default-features --example="$EXAMPLE" --target=wasm32-unknown-unknown -Z build-std-features=panic_immediate_abort -Z build-std=std,panic_abort -Z build-std-features="optimize_for_size"
time wasm-bindgen --out-name "$EXAMPLE" --no-typescript --out-dir web-src/wasm/examples --target web "target/wasm32-unknown-unknown/wasm-release/examples/$EXAMPLE.wasm"
time wasm-opt -all -Oz -ol 10 -s 10 -o "web-src/wasm/examples/${EXAMPLE}_bg.wasm" "web-src/wasm/examples/${EXAMPLE}_bg.wasm"
time gzip -9 -c "web-src/wasm/examples/${EXAMPLE}_bg.wasm" > "web-src/wasm/examples/${EXAMPLE}_bg.wasm.gz"
time brotli -9 -c "web-src/wasm/examples/${EXAMPLE}_bg.wasm" > "web-src/wasm/examples/${EXAMPLE}_bg.wasm.b"
cp "crates/bevy_dogoap/examples/$EXAMPLE.rs" "web-src/sources/$EXAMPLE.rs"
done
ls -hl web-src/wasm/examples/miner*