-
Notifications
You must be signed in to change notification settings - Fork 5
/
autobuild.sh
executable file
·122 lines (109 loc) · 2.92 KB
/
autobuild.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# This script is used to build the project automatically.
build_objs="$1"
rval=0
# Utility functions
function checkError() {
if [ "$?" != "0" ]; then
echo "Error: $1"
exit 1
fi
}
function moveFile() {
# Copy a file from one directory to another in a case-insensitive way
# Usage: copyFile <source> <destination>
local src_dir
src_dir="$(dirname "$1")"
local src_file
src_file="$(basename "$1")"
local dest
dest="$2"
# Find the file in a case-insensitive way and copy it
find "$src_dir" -maxdepth 1 -iname "$src_file" -exec mv {} "$dest" \;
}
# Check if the go command is installed
which go
checkError "Go is not installed!"
# Clean up the bin directory
rm -rf ./bin
mkdir ./bin
if [ "${build_objs}" == "all" ] ||
[ "${build_objs}" == "engine" ] ||
[ "${build_objs}" == "cr" ] ||
[ "${build_objs}" == "" ];
then
CGO_ENABLED=0 go build
rval=$?
if [ "${rval}" == "0" ]; then
echo "TheCrowler built successfully!"
moveFile TheCrowler ./bin
else
echo "TheCrowler build failed!"
exit $rval
fi
fi
if [ "${build_objs}" == "all" ] ||
[ "${build_objs}" == "addSource" ] ||
[ "${build_objs}" == "as" ] ||
[ "${build_objs}" == "" ];
then
cmd_name="addSource"
CGO_ENABLED=0 go build ./cmd/${cmd_name}
rval=$?
if [ "${rval}" == "0" ]; then
echo "${cmd_name} command line tool built successfully!"
moveFile ${cmd_name} ./bin
else
echo "${cmd_name} command line tool build failed!"
exit $rval
fi
fi
if [ "${build_objs}" == "all" ] ||
[ "${build_objs}" == "addCategory" ] ||
[ "${build_objs}" == "ac" ] ||
[ "${build_objs}" == "" ];
then
cmd_name="addCategory"
CGO_ENABLED=0 go build ./cmd/${cmd_name}
rval=$?
if [ "${rval}" == "0" ]; then
echo "${cmd_name} command line tool built successfully!"
moveFile ${cmd_name} ./bin
else
echo "${cmd_name} command line tool build failed!"
exit $rval
fi
fi
if [ "${build_objs}" == "all" ] ||
[ "${build_objs}" == "removeSource" ] ||
[ "${build_objs}" == "rs" ] ||
[ "${build_objs}" == "" ];
then
cmd_name="removeSource"
CGO_ENABLED=0 go build ./cmd/${cmd_name}
rval=$?
if [ "${rval}" == "0" ]; then
echo "${cmd_name} command line tool built successfully!"
moveFile ${cmd_name} ./bin
else
echo "${cmd_name} command line tool build failed!"
exit $rval
fi
fi
if [ "${build_objs}" == "all" ] ||
[ "${build_objs}" == "api" ] ||
[ "${build_objs}" == "" ];
then
cmd_name="api"
CGO_ENABLED=0 go build ./services/${cmd_name}
rval=$?
if [ "${rval}" == "0" ]; then
echo "${cmd_name} command line tool built successfully!"
moveFile ${cmd_name} ./bin
else
echo "${cmd_name} command line tool build failed!"
exit $rval
fi
fi
exit "$rval"
# Path: autobuild.sh