-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuilder
More file actions
executable file
·30 lines (28 loc) · 817 Bytes
/
builder
File metadata and controls
executable file
·30 lines (28 loc) · 817 Bytes
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
#!/bin/bash
function build() {
local WAT="$1"
local WASM="$(echo "$WAT" | sed 's/\wat$//g')wasm"
if [ "$WAT" -nt "$WASM" ]; then
rm -f "$WASM"
echo -en "\e[1;33m[BUILD]\e[1;37m $WAT -> $WASM\e[0m"
STATUS=0
BUILD_LOG="$(wat2wasm --enable-threads "$WAT" -o "$WASM" 2>&1 )" || STATUS=$?
if [[ "$STATUS" == "0" ]]; then
echo -e "\r[\e[1;32mOK\e[0m] "
else
echo -e "\r[\e[1;31mFAIL\e[0m] "
fi
if [[ "$BUILD_LOG" != "" ]]; then
echo "$BUILD_LOG"
fi
else
echo -e "\e[1;30mSkipping $WAT ($WASM up to date)\e[0m"
fi
}
if [[ "$1" != "" ]]; then
build $@
else
echo -e "[ \e[34mRun builder for all wat files in $(pwd)\e[0m ]"
find . -name '*.wat' -exec $0 {} \;
echo ""
fi