-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
28 lines (22 loc) · 1.07 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
#!/bin/bash
LOG_FILE="build.log"
touch $LOG_FILE 2>&1 | tee /dev/stderr
echo "----------------------------------------------------------------------------------------------------" | tee -a $LOG_FILE
echo "Build process started at: $(date)" | tee -a $LOG_FILE
echo "Removing web/go.wasm if it exists..." | tee -a $LOG_FILE
rm -f web/go.wasm 2>&1 | tee -a $LOG_FILE >&2
echo "Building a new web/go.wasm..." | tee -a $LOG_FILE
GOOS=js GOARCH=wasm go build -o=web/go.wasm -buildvcs=false main.go 2>&1 | tee -a $LOG_FILE >&2
status=$?
if [ $status -ne 0 ]; then
echo "Failed to build web/go.wasm" | tee -a $LOG_FILE >&2
exit 1
fi
echo "web/go.wasm was built." | tee -a $LOG_FILE
echo "Removing web/wasm_exec.js if it exists..." | tee -a $LOG_FILE
rm -f web/wasm_exec.js 2>&1 | tee -a $LOG_FILE >&2
echo "Fetching a new web/wasm_exec.js..." | tee -a $LOG_FILE
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" web/ 2>&1 | tee -a $LOG_FILE >&2
echo "web/wasm_exec.js was fetched from \$GOROOT/misc/wasm/" | tee -a $LOG_FILE
echo "Build process ended at: $(date)" | tee -a $LOG_FILE
exit