-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
78 lines (62 loc) · 1.22 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/bash
### dir structure
# /bfe
# /bfe-common
# /go
# /output
# /golang-lib
# /mini_spider
# build.sh
### restore working dir
WORKROOT=$(pwd)
cd ${WORKROOT}
# prepare PATH, GOROOT and GOPATH
export GOPATH=$(pwd)
# export golang-lib to GOPATH
cd ${WORKROOT}
export GOPATH=$(pwd)/../bfe-common/golang-lib:$GOPATH
# run go test for all subdirectory
cd ${WORKROOT}/src/mini_spider
go test -c -o ./testRun
if [ $? -ne 0 ];
then
echo "go compile test failed"
exit 1
fi
go test -run testRun
if [ $? -ne 0 ];
then
echo "go run test failed"
exit 1
fi
rm -rf ./testRun
echo "OK for go test"
### build
cd ${WORKROOT}/src/main
go build -o mini_spider
if [ $? -ne 0 ];
then
echo "fail to go build mini_spider.go"
exit 1
fi
echo "OK for go build mini_spider.go"
### create directory for output
cd ../../
if [ -d "./output" ]
then
rm -rf output
fi
mkdir output
# copy config
mkdir output/conf
cp conf/spider.conf output/conf
# copy data
cp -r data output/
# copy file to bin
mkdir output/bin
mv src/main/mini_spider output/bin
# create dir for log
mkdir output/log
# change mode of files in /bin
chmod +x output/bin/mini_spider
echo "OK for build mini_spider"