-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (28 loc) · 1.15 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
cmd := $(shell ls cmd/)
all: $(cmd)
Vendor= dearcode.net/netpi/vendor/
Project = $(Vendor)dearcode.net/doodle/pkg/service/debug.Project
GitHash = $(Vendor)dearcode.net/doodle/pkg/service/debug.GitHash
GitTime = $(Vendor)dearcode.net/doodle/pkg/service/debug.GitTime
GitMessage = $(Vendor)dearcode.net/doodle/pkg/service/debug.GitMessage
LDFLAGS += -X "$(Project)=dearcode.net/netpi"
LDFLAGS += -X "$(GitHash)=$(shell git log --pretty=format:'%H' -1)"
LDFLAGS += -X "$(GitTime)=$(shell git log --pretty=format:'%ct' -1)"
LDFLAGS += -X "$(GitMessage)=$(shell git log --pretty=format:'%cn %s %b' -1)"
source := $(shell ls -ld */|awk '$$NF !~ /bin\/|logs\/|config\/|_vendor\/|vendor\/|web\/|Godeps\/|docs\// {printf $$NF" "}')
golint:
go get golang.org/x/lint/golint
staticcheck:
go get honnef.co/go/tools/cmd/staticcheck
lint: golint staticcheck
for path in $(source); do golint "$$path..."; done;
for path in $(source); do gofmt -s -l -w $$path; done;
go vet ./...
staticcheck ./...
clean:
@rm -rf bin
.PHONY: $(cmd)
$(cmd):
go build -o bin/$@ -ldflags '$(LDFLAGS)' cmd/$@/*
test:
@for path in $(source); do echo "go test ./$$path"; go test "./"$$path; done;