forked from multiversx/mx-sdk-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwat-build.sh
executable file
·38 lines (30 loc) · 1.12 KB
/
wat-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
#!/bin/bash
## To use the complete wat build, install wasm2wat and wasm2c and add to PATH.
CONTRACT_PATH=$1
CONTRACT_NAME=${CONTRACT_PATH##*/}
rm -f ${CONTRACT_PATH}/output/${CONTRACT_NAME}.wasm
rm -f ${CONTRACT_PATH}/output/${CONTRACT_NAME}.wat
rm -f ${CONTRACT_PATH}/output/${CONTRACT_NAME}-dbg.wasm
rm -f ${CONTRACT_PATH}/output/${CONTRACT_NAME}-dbg.c
rm -f ${CONTRACT_PATH}/output/${CONTRACT_NAME}-dbg.wat
cd ${CONTRACT_PATH}/meta
cargo run build
cargo run build --wasm-symbols --wasm-suffix "dbg" --no-wasm-opt
cd ../output
wasm2wat \
${CONTRACT_NAME}.wasm \
-o \
${CONTRACT_NAME}.wat
wasm2wat \
${CONTRACT_NAME}-dbg.wasm \
-o \
${CONTRACT_NAME}-dbg.wat
wasm2c \
${CONTRACT_NAME}-dbg.wasm \
-o \
${CONTRACT_NAME}-dbg.c
# Twiggy helps us investigate where the size/functions come from
twiggy top -n 200 ${CONTRACT_NAME}-dbg.wasm > twiggy-top-${CONTRACT_NAME}.txt
twiggy paths ${CONTRACT_NAME}-dbg.wasm > twiggy-paths-${CONTRACT_NAME}.txt
twiggy monos ${CONTRACT_NAME}-dbg.wasm > twiggy-monos-${CONTRACT_NAME}.txt
twiggy dominators ${CONTRACT_NAME}-dbg.wasm > twiggy-dominators-${CONTRACT_NAME}.txt