-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·61 lines (57 loc) · 1.38 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
echo "Checking golang"
go_cmd=$(which go)
if [[ $? != 0 ]]
then
echo "Golang binary not found, trying to install..."
if [[ "${platform,,}" == "darwin" ]]
then
out=$(brew install golang)
else
out=$(yum install golang)
fi
if [[ $? != 0 ]]
then
echo "Failed to install golang, please check the above message"
echo "${out}"
exit $?
fi
else
echo "Using golang from ${go_cmd}"
fi
# Check ragel's presense
echo "Checking ragel..."
ragel_cmd=$(which ragel)
rc=$?
platform=$(uname)
helper="src/ua"
if [[ $rc != 0 ]]; then
echo "Installing Ragel..."
if [[ "${platform,,}" == "darwin" ]]
then
out=$(brew install ragel)
else
out=$(yum install ragel)
fi
if [[ $? != 0 ]]
then
echo "Failed to install ragel, please check the above message"
echo "${out}"
exit $?
fi
else
echo "Ragel found in ${ragel_cmd} \n"
fi
set -e
echo "Building .rl files in ${helper} folder"
if [ "$GOENV" = "production" ]; then
echo -e "Optimise code generation set to true in ${GOENV}\n"
ragel_opts='-Z -G2'
else
ragel_opts='-Z'
echo "Unoptimise ragel code generation in dev mode"
fi
ragel ${ragel_opts} ./is_mobile.rl -o ${helper}/is_mobile.go
ragel ${ragel_opts} ./ua_version.rl -o ${helper}/ua_version.go
ragel ${ragel_opts} ./is_bot.rl -o ${helper}/is_bot.go
echo "Ragel build successful\n"
echo "==================================\n"