-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
84 lines (73 loc) · 1.61 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
NAME := mog
# for build
VERSION := v0.1.6
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\""
# for dist
DIST_DIRS := find * -type d -exec
.PHONY: setup
## Install dev dependencies
setup:
go get github.com/golang/dep/cmd/dep
go get github.com/golang/lint/golint
go get golang.org/x/tools/cmd/goimports
.PHONY: clean
## Clean resources
clean:
rm -rf bin/*
rm -rf dist/*
rm -rf vendor/*
.PHONY: test
## Run tests
test: deps
go test -cover -v $(go list ./... | grep -v /vendor/)
.PHONY: install
## Install binary to $GOPATH/bin
install: deps
go install $(LDFLAGS)
.PHONY: build
## Run build binary to bin
build: deps
go build $(LDFLAGS) -o bin/$(NAME)
.PHONY: cross-build
## Run cross build
cross-build: deps
for os in darwin linux windows; do \
for arch in amd64 386; do \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 \
go build $(LDFLAGS) -o dist/$$os-$$arch/$(NAME); \
done; \
done
.PHONY: dist
## Make dist
dist:
cd dist && \
for os in darwin linux windows; do \
for arch in amd64 386; do \
cd $$os-$$arch && \
tar -zcvf ../$(NAME)_$$os\_$$arch.tar.gz . && \
cd ..; \
done; \
done && \
$(DIST_DIRS) rm -rf {} + && \
shasum -a 256 * > sha256sums.txt && \
cd ..
.PHONY: deps
## Install dependencies
deps: setup
dep ensure
.PHONY: update
## Update all dependencies
update: setup
dep ensure -update
.PHONY: lint
## Lint
lint: setup
go vet -v
for pkg in $$(go list ./... | grep -v /vendor/); do \
golint --set_exit_status $$pkg || exit $$?; \
done
.PHONY: fmt
## Format source codes
fmt: setup
goimports -w