-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
89 lines (70 loc) · 2.5 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
##################### CARAVELA's MAKEFILE #########################
GOCMD=go
###################### Builtin GO tools ###########################
GOBUILD=$(GOCMD) build
GOINSTALL=$(GOCMD) install
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
GOGET=$(GOCMD) get
###################### External GO tools ###########################
GOLINT=golint
GOCOV=gocov
GOCOVHTML=gocov-html
GODEPGRAPH=godepgraph
######################### Output Files #############################
EXE=.exe
BINARY_NAME=caravela$(EXE)
BINARY_NAME_LINUX=$(BINARY_NAME)_linux$(EXE)
BINARY_NAME_WIN=$(BINARY_NAME)_win$(EXE)
########################## COMMANDS ################################
all: build test
build:
@echo Building for the current machine settings...
$(GOBUILD) -o $(BINARY_NAME) -v
build-linux:
@echo Building for linux...
env GOOS=linux $(GOBUILD) -o $(BINARY_NAME) -v
build-windows:
@echo Building for windows...
env GOOS=windows $(GOBUILD) -o $(BINARY_NAME) -v
clean:
@echo Cleaning project...
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME_LINUX)
rm -f $(BINARY_NAME_WIN)
install:
@echo Installing CARAVELA in the local GO environment...
$(GOINSTALL) -v -gcflags "-N -l" .
test:
@echo Testing...
$(GOTEST) -v ./...
test-cov:
@echo Testing and coverage report generation...
$(GOCOV) test ./... | $(GOCOVHTML) > coverage.html
test-verify:
$(MAKE) test
@echo Running vet tool to static analyze the code
$(GOVET) -v ./...
@echo Running lint tool to static analyze the code style
dep-graph:
@echo Generating package import dependency graph...
$(GODEPGRAPH) -s -p github.com/docker github.com/strabox/caravela | dot -Tpng -o importsGraph.png
docker-build:
@echo Building Docker container...
docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest .
docker-upload:
@echo Building Docker container and uploading to DockerHub...
docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest .
docker push strabox/caravela:latest
install-external-tools:
@echo Installing external tools...
@echo Installing lint - Code style analyzer (from google)
$(GOGET) github.com/golang/lint
@echo Installing gocov - Code coverage generator
$(GOGET) github.com/axw/gocov/gocov
@echo Installing gocov-html - Code coverage html generator
$(GOGET) -u gopkg.in/matm/v1/gocov-html
@echo Installing godepgraph - Code package dependency graph generator
$(GOGET) github.com/kisielk/godepgraph