-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
69 lines (55 loc) · 1.24 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
66
67
68
69
LDFLAGS ?= -s -w
SRC_ROOT = .
CLI_DIR = $(SRC_ROOT)/cli
BIN_DIR = $(SRC_ROOT)/bin
BIN_CLI = $(BIN_DIR)/beezim-cli
# Go parameters
GOCMD ?= go
GOBUILD = $(GOCMD) build -v
GOCLEAN = $(GOCMD) clean
GOTEST = $(GOCMD) test -v -failfast
GORACE = GORACE="halt_on_error=1"
GOTEST_RACE = $(GORACE) $(GOTEST) -v -race
ifndef $(GOPATH)
GOPATH=$(shell echo $(shell $(GOCMD) env GOPATH) | sed -E "s;(.*):.*;\1;")
export GOPATH
endif
all: build
build: bin
@echo "+ building beezim source"
$(GOBUILD) -o $(BIN_CLI) $(CLI_DIR)
bin:
@mkdir $@
install:
@echo "+ installing beezim-cli"
$(GOBUILD) -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_CLI) $(CLI_DIR)
ifneq ("$(GOPATH)","")
@mv $(BIN_CLI) $(GOPATH)/$(BIN_CLI)
endif
.PHONY: test
test:
@echo "+ executing tests"
$(GOCLEAN) -testcache && $(GOTEST) $(SRC_ROOT)/...
.PHONY: racetest
racetest:
@echo "+ building tests using Race Detector"
$(GOTEST_RACE) $(SRC_ROOT)/...
.PHONY: clean
clean:
@echo "+ cleaning"
$(GOCLEAN) -i -cache ./...
@rm -r $(BIN_DIR)
.PHONY: codecheck
codecheck: fmt lint vet
.PHONY: fmt
fmt:
@echo "+ go fmt"
$(GOCMD) fmt $(SRC_ROOT)/...
.PHONY: lint
lint:
@echo "+ go lint"
@golint -min_confidence=0.1 $(SRC_ROOT)/...
.PHONY: vet
vet:
@echo "+ go vet"
$(GOCMD) vet $(SRC_ROOT)/...