forked from erwanvivien/fast_qr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wasm-pack.sh
executable file
·36 lines (27 loc) · 1.09 KB
/
wasm-pack.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
30
31
32
33
34
35
36
#!/bin/sh
date=$(date +%s)
cleanup()
{
rustup override set stable
}
rustup override set nightly # > /dev/null 2>&1
trap "cleanup" EXIT
echo "\033[90m[INFO]\033[0m Using nightly rustc\n"
mkdir -p pkg/bz2
# Build wasm package
wasm-pack build -t web --release \
--features svg \
--manifest-path ./Cargo.toml \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# Optimize wasm package
bzip2 pkg/fast_qr_bg.wasm -kc > "pkg/bz2/${date}_fast_qr_bg_build.wasm.bz2"
wasm-opt -Os --dce -o pkg/fast_qr_bg.wasm pkg/fast_qr_bg.wasm # Optional
bzip2 pkg/fast_qr_bg.wasm -kc > "pkg/bz2/${date}_fast_qr_bg_opt1.wasm.bz2"
wasm-opt -Os --dce -o pkg/fast_qr_bg.wasm pkg/fast_qr_bg.wasm # Optional
bzip2 pkg/fast_qr_bg.wasm -kc > "pkg/bz2/${date}_fast_qr_bg_opt2.wasm.bz2"
echo
echo "\033[92m[OUT ]\033[0m $(du -b pkg/bz2/${date}_fast_qr_bg_build.wasm.bz2)"
echo "\033[92m[OUT ]\033[0m $(du -b pkg/bz2/${date}_fast_qr_bg_opt1.wasm.bz2)"
echo "\033[92m[OUT ]\033[0m $(du -b pkg/bz2/${date}_fast_qr_bg_opt2.wasm.bz2)"
cleanup > /dev/null 2>&1
echo "\n\033[90m[INFO]\033[0m Using stable rustc"