-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
40 lines (25 loc) · 992 Bytes
/
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
cmd := $(shell ls cmd/)
all: $(cmd)
GitHash := dearcode.net/doodle/pkg/util.GitHash
GitTime := dearcode.net/doodle/pkg/util.GitTime
GitMessage := dearcode.net/doodle/pkg/util.GitMessage
LDFLAGS += -X "$(GitHash)=$(shell git log --pretty=format:'%H' -1)"
LDFLAGS += -X "$(GitTime)=$(shell git log --pretty=format:'%cd' -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/$@/main.go
test:
@for path in $(source); do echo "go test ./$$path"; go test "./"$$path; done;