-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·98 lines (83 loc) · 2.3 KB
/
build.sh
File metadata and controls
executable file
·98 lines (83 loc) · 2.3 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -euo pipefail
WEBPACK_DEV_CONFIG="build/webpack.dev.js"
WEBPACK_PROD_CONFIG="build/webpack.prod.js"
WEBPACK_CONFIG="$WEBPACK_DEV_CONFIG"
hashfile="build/out/hash"
export GOOS=""
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "build.sh - wrapper script for building isolate"
echo ""
echo "flags:"
echo "--prod production webpack build (dev is default)"
echo "--os=OS cross compile daemon for another build (accepted: 'linux', 'windows', 'darwin')"
exit 0
;;
--prod)
WEBPACK_CONFIG="$WEBPACK_PROD_CONFIG"
rm "$hashfile"
shift
;;
--os*)
export GOOS=`echo $1 | sed -e 's/^[^=]*=//g'`
shift
;;
*)
break
;;
esac
done
mkdir -p build/out/
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
OVERWRITE='\e[1A'
starting() {
echo -e "- ${NC}$*$NC"
}
finished() {
echo -en "\e[1A"
echo -e "⚡ ${GREEN}$*${NC}"
}
if ! hash go > /dev/null ;
then
echo -e "${RED}ERROR: golang-go not available, building daemon will fail${NC}\n"
exit 1
fi
GOVERSION=$(go version)
if [[ "$GOVERSION" != *1.11* ]];
then
echo -e "${YELLOW}WARNING: golang-go version '${GOVERSION}', only tested with 1.11 ${NC}\n"
fi
step="BUILDING GO DAEMON (ISOLATED)"
starting "$step"
(
cd src/isolated/
if [[ "$GOOS" == "windows" ]];
then
# use mingw-w64 to cross compile windows
# only tested on linux cross compiling for windows
CC=x86_64-w64-mingw32-gcc-posix CGO_ENABLED=1 go build -o ../../build/out/isolated.exe
else
go build -o ../../build/out/isolated
fi
)
finished "$step"
step="BUILDING CSS"
starting "$step"
cat src/css/main.styl | npx stylus > build/out/style.css
finished "$step"
step="BUILDING WEBPACK"
if [[ $(cat $hashfile) == $(find src/ -type f -iname '*.tsx' | xargs shasum -a 256) ]];
then
starting "$step"
finished "$step (NO CHANGES, SEE $hashfile)"
else
starting "$step"
find src/ -type f -iname '*.tsx' | xargs shasum -a 256 > $hashfile
npx webpack --config "$WEBPACK_CONFIG" --progress
# Webpack prints a lot so don't bother finishing
fi