This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (52 loc) · 2.02 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
# Variables
BUILD_DIR := dist
GITHASH := $(shell git rev-parse HEAD)
LINT_PATHS := ./core/... ./cmd/... ./router/... ./api/... achievements.go
FORMAT_PATHS := ./core ./cmd ./router ./api achievements.go
DEADLINE := 60s
# Compilation variables
CC := go build
DFLAGS := -race
CFLAGS := -X github.com/FlorentinDUBOIS/achievements/cmd.githash=$(GITHASH)
CROSS := GOOS=linux GOARCH=amd64
# Makefile variables
VPATH := $(BUILD_DIR)
# Function definitions
rwildcard := $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
.SECONDEXPANSION:
.PHONY: all
all: init format lint release
.PHONY: init
init: dep
go get -u github.com/golang/dep
go get -u github.com/alecthomas/gometalinter
gometalinter --install --update
.PHONY: dep
dep:
dep ensure
.PHONY: format
format:
gofmt -w -s $(FORMAT_PATHS)
.PHONY: lint
lint:
gometalinter --vendor --deadline=$(DEADLINE) --disable-all --enable=gofmt $(LINT_PATHS)
gometalinter --vendor --deadline=$(DEADLINE) --disable-all --enable=vet $(LINT_PATHS)
gometalinter --vendor --deadline=$(DEADLINE) --disable-all --enable=golint $(LINT_PATHS)
gometalinter --vendor --deadline=$(DEADLINE) --disable-all --enable=ineffassign $(LINT_PATHS)
gometalinter --vendor --deadline=$(DEADLINE) --disable-all --enable=misspell $(LINT_PATHS)
gometalinter --vendor --deadline=$(DEADLINE) --disable-all --enable=staticcheck $(LINT_PATHS)
gometalinter --vendor --deadline=$(DEADLINE) --disable-all --enable=gas $(LINT_PATHS)
.PHONY: dev
dev: format lint build
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
.PHONY: build
build: achievements.go $$(call rwildcard, ./, *.go)
$(CC) $(DFLAGS) -ldflags "$(CFLAGS)" -o $(BUILD_DIR)/achievements.build achievements.go
.PHONY: release
release: achievements.go $$(call rwildcard, ./, *.go)
$(CC) -ldflags "-s -w $(CFLAGS)" -o $(BUILD_DIR)/achievements.release achievements.go
.PHONY: dist
dist: achievements.go $$(call rwildcard, ./, *.go)
$(CROSS) $(CC) -ldflags "-s -w $(CFLAGS)" -o $(BUILD_DIR)/achievements.dist achievements.go