-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
54 lines (44 loc) · 1.1 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
# init project path
HOMEDIR := $(shell pwd)
OUTDIR := $(HOMEDIR)/build
CONFDIR := $(HOMEDIR)/conf
DATADIR := $(HOMEDIR)/data
# init command params
GO := ${GOROOT}/bin/go
GOROOT := ${GOROOT}
GOPATH := $(shell $(GO) env GOPATH)
GOMOD := $(GO) mod
GOBUILD := $(GO) build -trimpath
GOTEST := $(GO) test -gcflags="-N -l"
GOPKGS := $$($(GO) list ./...| grep -vE "vendor")
# make, make all
all: prepare clean compile package
#make prepare, download dependencies
prepare: gomod
gomod:
$(GOMOD) download
#make compile
compile: build
build:
$(GOBUILD) -o $(HOMEDIR)/go-spider
# make test, test your code
test: prepare test-case
test-case:
$(GOTEST) -v -cover $(GOPKGS)
# make package
package: package-bin package-conf package-data
package-bin:
mkdir -p $(OUTDIR)/bin
mv go-spider $(OUTDIR)/bin
package-conf:
mkdir -p $(OUTDIR)/conf
cp -r $(CONFDIR)/* $(OUTDIR)/conf
package-data:
mkdir -p $(OUTDIR)/data
cp -r $(DATADIR)/* $(OUTDIR)/data
# make clean
clean:
rm -rf $(OUTDIR)
rm -rf $(HOMEDIR)/go-spider
# avoid filename conflict and speed up build
.PHONY: all prepare compile test package clean build