-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
80 lines (64 loc) · 1.93 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
VERSION := 0.0.1
PKG := arso
COMMIT := $(shell git rev-parse HEAD)
BUILD_TIME := $(shell date -u +%FT%T)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
CURRENT_TARGET = $(PKG)-$(shell uname -s)-$(shell uname -m)
TARGETS := Linux-amd64-x86_64
os = $(word 1, $(subst -, ,$@))
arch = $(word 3, $(subst -, ,$@))
goarch = $(word 2, $(subst -, ,$@))
goos = $(shell echo $(os) | tr A-Z a-z)
output = $(PKG)-$(os)-$(arch)
version_flags = -X $(PKG)/version.Version=$(VERSION) \
-X $(PKG)/version.CommitHash=${COMMIT} \
-X $(PKG)/version.Branch=${BRANCH} \
-X $(PKG)/version.BuildTime=${BUILD_TIME}
.PHONY: $(TARGETS)
$(TARGETS):
env GOOS=$(goos) GOARCH=$(goarch) go build --ldflags '-s -w $(version_flags)' -o $(output) $(PKG)
#
# Build all defined targets
#
.PHONY: build
build: $(TARGETS)
#
# Install app for current system
#
install: build
sudo mv $(CURRENT_TARGET) /usr/local/bin/$(PKG)
#
# Install locked dependecies
#
sync: bin/dep
cd src/$(PKG); dep ensure
#
# Update all locked dependecies
#
update: bin/dep
cd src/$(PKG); dep ensure -update
bin/dep:
go get -u github.com/golang/dep/cmd/dep
bin/github-release:
go get github.com/aktau/github-release
bin/gocov:
go get -u github.com/axw/gocov/gocov
bin/gometalinter:
go get -u github.com/alecthomas/gometalinter
bin/gometalinter --install --update
deps:
go get -u github.com/laher/gols/cmd/...
clean:
rm -f $(PKG)
rm -rf pkg
rm -rf bin
find src/* -maxdepth 0 ! -name '$(PKG)' -type d | xargs rm -rf
rm -rf src/$(PKG)/vendor/
lint: bin/gometalinter
bin/gometalinter --fast --disable=gotype --disable=gosimple --disable=ineffassign --disable=dupl --disable=gas --cyclo-over=30 --deadline=60s --exclude $(shell pwd)/src/$(PKG)/vendor src/$(PKG)/...
find src/$(PKG) -not -path "./src/$(PKG)/vendor/*" -name '*.go' | xargs gofmt -w -s
test: deps
go test -v -race $(shell go-ls $(PKG)/...)
cover: bin/gocov
gocov test $(shell go-ls $(PKG)/...) | gocov report
all: sync deps build test cover