forked from G-Node/gin-doi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (31 loc) · 1006 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
40
41
42
43
44
45
46
# full pkg name
PKG = github.com/G-Node/gin-doi
# Binary
APP = gindoid
# Build loc
BUILDLOC = build
# Install location
INSTLOC = $(GOPATH)/bin
cwd = $(shell pwd)
# Build flags
VERNUM = $(shell cut -d= -f2 version)
ncommits = $(shell git rev-list --count HEAD)
BUILDNUM = $(shell printf '%06d' $(ncommits))
COMMITHASH = $(shell git rev-parse HEAD)
LDFLAGS = -ldflags="-X main.appversion=$(VERNUM) -X main.build=$(BUILDNUM) -X main.commit=$(COMMITHASH)"
SOURCES = $(shell find . -type f -iname "*.go") version go.mod go.sum
.PHONY: $(APP) install clean uninstall test
$(APP): $(BUILDLOC)/$(APP)
install: $(APP)
install $(BUILDLOC)/$(APP) $(INSTLOC)/$(APP)
clean:
rm -rf $(BUILDLOC)
uninstall:
rm $(INSTLOC)/$(APP)
$(BUILDLOC)/$(APP): $(SOURCES)
go build -trimpath $(LDFLAGS) $(GCFLAGS) -o $(BUILDLOC)/$(APP) ./cmd/gindoid
test: coverage
coverage: $(SOURCES)
go test -race -coverpkg=./... -coverprofile=coverage ./...
coverage.html: coverage
go tool cover -html=coverage -o coverage.html