forked from rustwasm/wee_alloc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·84 lines (62 loc) · 1.92 KB
/
build.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
set -eux
cd $(dirname $0)
cargo readme -r wee_alloc -t "$(pwd)/README.tpl" > README.md
cd ./wee_alloc
cargo build
cargo build --features size_classes
cd -
cd ./test
cargo build --release
cargo build --release --features size_classes
cd -
cd ./trace-malloc-free
cargo build
cd -
cd ./example
cargo build
cargo build --features size_classes
cargo build --release --target wasm32-unknown-unknown
wasm-gc ../target/wasm32-unknown-unknown/release/wee_alloc_example.wasm \
../target/wasm32-unknown-unknown/release/wee_alloc_example.gc.wasm
if which wasm-opt; then
wasm-opt -Oz \
../target/wasm32-unknown-unknown/release/wee_alloc_example.gc.wasm \
-o ../target/wasm32-unknown-unknown/release/wee_alloc_example.gc.opt.wasm
fi
cargo build --release --features size_classes --target wasm32-unknown-unknown
wasm-gc ../target/wasm32-unknown-unknown/release/wee_alloc_example.wasm \
../target/wasm32-unknown-unknown/release/wee_alloc_example.size_classes.gc.wasm
if which wasm-opt; then
wasm-opt -Oz \
../target/wasm32-unknown-unknown/release/wee_alloc_example.size_classes.gc.wasm \
-o ../target/wasm32-unknown-unknown/release/wee_alloc_example.size_classes.gc.opt.wasm
fi
wc -c ../target/wasm32-unknown-unknown/release/*.wasm
set +x
function dis_does_not_contain {
local matches=$(wasm-dis "$1" | grep "$2")
if [[ "$matches" != "" ]]; then
echo "ERROR! found $2 in $1:"
echo
echo "$matches"
echo
echo "wee_alloc should never pull in the panicking infrastructure"
exit 1
fi
}
function no_panic {
dis_does_not_contain $1 "panic"
}
function no_fmt {
dis_does_not_contain $1 "fmt"
}
function no_write {
dis_does_not_contain $1 "Write"
}
for x in ../target/wasm32-unknown-unknown/release/*.gc.wasm; do
no_panic "$x"
no_fmt "$x"
no_write "$x"
done
cd -