-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (36 loc) · 1.09 KB
/
Makefile
File metadata and controls
48 lines (36 loc) · 1.09 KB
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
PACKAGE := github.com/github/git-sizer
ROOTDIR := $(abspath $(CURDIR))
GOPATH := $(ROOTDIR)/.gopath
export GOPATH
GO := $(CURDIR)/script/go
GOFMT := $(CURDIR)/script/gofmt
BIN := bin
GOFLAGS := \
--tags "static" \
-ldflags "-X main.BuildVersion=$(shell git rev-parse HEAD) -X main.BuildDescribe=$(shell git describe --tags --always --dirty)"
GO_CMDS := $(BIN)/git-sizer
GO_PKGS := $(shell cd .gopath/src && find github.com/github/git-sizer/ -type f -name '*.go' | xargs -n1 dirname | grep -v '^github.com/github/git-sizer/vendor/' | sort -u)
GO_SRCS := $(shell find src -type f -name '*.go')
.PHONY: all
all: $(GO_CMDS)
$(BIN)/%: $(GO_SRCS) | $(BIN)
$(GO) build $(GOFLAGS) -o $@ $(PACKAGE)/$*
$(BIN):
mkdir -p $(BIN)
.PHONY: test
test: $(GO_CMDS) gotest
.PHONY: gotest
gotest:
$(GO) test -timeout 60s $(GOFLAGS) $(GO_PKGS)
.PHONY: gofmt
gofmt:
find src test -name "*.go" -print0 | xargs -0 $(GOFMT) -l -w | sed -e 's/^/Fixing /'
.PHONY: goimports
goimports:
find src -name "*.go" -print0 | xargs -0 goimports -l -w -e
.PHONY: govet
govet:
$(GO) vet $(GO_PKGS)
.PHONY: clean
clean:
rm -rf bin