forked from infinilabs/crawler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
209 lines (171 loc) · 7.02 KB
/
Makefile
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
SHELL=/bin/bash
# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
CURDIR := $(shell pwd)
OLDGOPATH:= $(GOPATH)
NEWGOPATH:= $(GOPATH):$(CURDIR)/vendor
GO := GO15VENDOREXPERIMENT="1" go
GOBUILD := GOPATH=$(NEWGOPATH) CGO_ENABLED=1 $(GO) build -ldflags -s
GOTEST := GOPATH=$(NEWGOPATH) CGO_ENABLED=1 $(GO) test -ldflags -s
ARCH := "`uname -s`"
LINUX := "Linux"
MAC := "Darwin"
GO_FILES=$(find . -iname '*.go' | grep -v /vendor/)
PKGS=$(go list ./... | grep -v /vendor/)
.PHONY: all build update test clean
default: clean build
build: config update-ui update-template-ui
@echo $(GOPATH)
@echo $(NEWGOPATH)
$(GOBUILD) -o bin/gopa
cp gopa.yml bin/gopa.yml
cp -r config bin
build-cluster-test: build
cd bin && mkdir node1 node2 node3 && cp gopa node1 && cp gopa node2 && cp gopa node3
# used to build the binary for gdb debugging
build-grace: clean config update-ui
$(GOBUILD) -gcflags "-N -l" -race -o bin/gopa
update-ui:
$(GO) get github.com/infinitbyte/esc
(cd static&& esc -ignore="static.go|build_static.sh|.DS_Store" -o static.go -pkg static ../static )
update-template-ui:
$(GO) get github.com/infinitbyte/ego/cmd/ego
cd modules/ui/ && ego
tar: build
cd bin && tar cfz ../bin/gopa.tar.gz gopa config gopa.yml
cross-build: clean config update-ui
$(GO) test
GOOS=windows GOARCH=amd64 $(GOBUILD) -o bin/windows64/gopa.exe
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o bin/darwin64/gopa
GOOS=linux GOARCH=amd64 $(GOBUILD) -o bin/linux64/gopa
build-win: clean config update-ui
GOOS=windows GOARCH=amd64 $(GOBUILD) -o bin/windows64/gopa.exe
GOOS=windows GOARCH=386 $(GOBUILD) -o bin/windows32/gopa.exe
build-linux: clean config update-ui
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o bin/linux64/gopa --tags "libsqlite3 linux"
GOOS=linux GOARCH=386 CGO_ENABLED=1 go build -o bin/linux32/gopa --tags "libsqlite3 linux"
all: clean config update-ui cross-build
all-platform: clean config update-ui cross-build-all-platform
cross-build-all-platform: clean config build-bsd
GOOS=windows GOARCH=amd64 $(GOBUILD) -o bin/windows64/gopa.exe
GOOS=windows GOARCH=386 $(GOBUILD) -o bin/windows32/gopa.exe
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o bin/darwin64/gopa
GOOS=darwin GOARCH=386 $(GOBUILD) -o bin/darwin32/gopa
GOOS=linux GOARCH=amd64 $(GOBUILD) -o bin/linux64/gopa
GOOS=linux GOARCH=386 $(GOBUILD) -o bin/linux32/gopa
GOOS=linux GOARCH=arm $(GOBUILD) -o bin/linux_arm/gopa
build-bsd:
GOOS=freebsd GOARCH=amd64 $(GOBUILD) -o bin/freebsd64/gopa
GOOS=freebsd GOARCH=386 $(GOBUILD) -o bin/freebsd32/gopa
GOOS=netbsd GOARCH=amd64 $(GOBUILD) -o bin/netbsd64/gopa
GOOS=netbsd GOARCH=386 $(GOBUILD) -o bin/netbsd32/gopa
GOOS=openbsd GOARCH=amd64 $(GOBUILD) -o bin/openbsd64/gopa
GOOS=openbsd GOARCH=386 $(GOBUILD) -o bin/openbsd32/gopa
format:
gofmt -l -s -w .
clean_data:
rm -rif dist
rm -rif data
rm -rif log
clean: clean_data
rm -rif bin
mkdir bin
mkdir bin/windows64
mkdir bin/linux64
mkdir bin/darwin64
update-commit-log:
echo -e "package env\nconst lastCommitLog =\""`git log -1 --pretty=format:"%h, %ad, %an, %s"` "\"\nconst buildDate =\"`date`\"" > core/env/commit_log.go
config: update-commit-log
@echo "init config"
$(GO) env
fetch-depends:
@echo "get Dependencies"
$(GO) get github.com/cihub/seelog
$(GO) get github.com/robfig/config
$(GO) get github.com/PuerkitoBio/purell
$(GO) get github.com/clarkduvall/hyperloglog
$(GO) get github.com/PuerkitoBio/goquery
$(GO) get github.com/syndtr/goleveldb/leveldb
$(GO) get github.com/jmoiron/jsonq
$(GO) get github.com/gorilla/websocket
$(GO) get github.com/boltdb/bolt/...
$(GO) get github.com/alash3al/goemitter
$(GO) get github.com/bkaradzic/go-lz4
$(GO) get github.com/elgs/gojq
$(GO) get github.com/kardianos/osext
$(GO) get github.com/zeebo/sbloom
$(GO) get github.com/asdine/storm
$(GO) get github.com/julienschmidt/httprouter
$(GO) get github.com/rs/xid
$(GO) get github.com/seiflotfy/cuckoofilter
$(GO) get github.com/hashicorp/raft
$(GO) get github.com/hashicorp/raft-boltdb
$(GO) get github.com/jaytaylor/html2text
$(GO) get github.com/asdine/storm/codec/protobuf
$(GO) get github.com/ryanuber/go-glob
$(GO) get github.com/gorilla/sessions
$(GO) get github.com/mattn/go-sqlite3
$(GO) get github.com/jinzhu/gorm
$(GO) get github.com/stretchr/testify/assert
$(GO) get github.com/spf13/viper
$(GO) get -t github.com/RoaringBitmap/roaring
$(GO) get github.com/elastic/go-ucfg
$(GO) get github.com/jasonlvhit/gocron
$(GO) get github.com/blevesearch/bleve
$(GO) get github.com/gensmusic/simhash
$(GO) get github.com/gensmusic/jiebago/...
$(GO) get github.com/quipo/statsd
$(GO) get github.com/go-sql-driver/mysql
dist: cross-build package
dist-major-platform: all package
dist-all-platform: all-platform package-all-platform
package:
@echo "Packaging"
cd bin && tar cfz ../bin/darwin64.tar.gz darwin64
cd bin && tar cfz ../bin/linux64.tar.gz linux64
cd bin && tar cfz ../bin/windows64.tar.gz windows64
package-all-platform:
@echo "Packaging"
cd bin && tar cfz ../bin/windows64.tar.gz windows64/gopa.exe
cd bin && tar cfz ../bin/windows32.tar.gz windows32/gopa.exe
cd bin && tar cfz ../bin/darwin64.tar.gz darwin64/gopa
cd bin && tar cfz ../bin/darwin32.tar.gz darwin32/gopa
cd bin && tar cfz ../bin/linux64.tar.gz linux64/gopa
cd bin && tar cfz ../bin/linux32.tar.gz linux32/gopa
cd bin && tar cfz ../bin/linux_arm.tar.gz linux_arm/gopa
cd bin && tar cfz ../bin/freebsd64.tar.gz freebsd64/gopa
cd bin && tar cfz ../bin/freebsd32.tar.gz freebsd32/gopa
cd bin && tar cfz ../bin/netbsd64.tar.gz netbsd64/gopa
cd bin && tar cfz ../bin/netbsd32.tar.gz netbsd32/gopa
cd bin && tar cfz ../bin/openbsd64.tar.gz openbsd64/gopa
cd bin && tar cfz ../bin/openbsd32.tar.gz openbsd32/gopa
test:
go get -u github.com/kardianos/govendor
go get github.com/stretchr/testify/assert
govendor test +local
#$(GO) test -timeout 60s ./... --ignore ./vendor
#GORACE="halt_on_error=1" go test ./... -race -timeout 120s --ignore ./vendor
check:
$(GO) get github.com/golang/lint/golint
$(GO) get honnef.co/go/tools/cmd/megacheck
test -z $(gofmt -s -l $GO_FILES) # Fail if a .go file hasn't been formatted with gofmt
$(GO) test -v -race $(PKGS) # Run all the tests with the race detector enabled
$(GO) vet $(PKGS) # go vet is the official Go static analyzer
@echo "go tool vet"
go tool vet main.go
go tool vet core
go tool vet modules
megacheck $(PKGS) # "go vet on steroids" + linter
golint -set_exit_status $(PKGS) # one last linter
errcheck:
go get github.com/kisielk/errcheck
errcheck -blank $(PKGS)
cover:
go get github.com/mattn/goveralls
go test -v -cover -race -coverprofile=data/coverage.out
goveralls -coverprofile=data/coverage.out -service=travis-ci -repotoken=$COVERALLS_TOKEN
cyclo:
go get -u github.com/fzipp/gocyclo
gocyclo -top 10 -over 12 $$(ls -d */ | grep -v vendor)