This repository has been archived by the owner on Aug 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
72 lines (58 loc) · 1.86 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
GO = go
GOX = gox
GOX_ARGS = -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" -osarch="linux/amd64 linux/386 linux/arm linux/arm64 darwin/amd64 freebsd/amd64 freebsd/386 windows/386 windows/amd64"
APP = nats_exporter
DIR = $(shell pwd)
NO_COLOR = \033[0m
OK_COLOR = \033[32;01m
ERROR_COLOR = \033[31;01m
WARN_COLOR = \033[33;01m
MAKE_COLOR = \033[33;01m%-20s\033[0m
SRCS = $(shell git ls-files '*.go' | grep -v '^vendor/')
BUILD_DIR = build/
.DEFAULT_GOAL := build
.PHONY: help
help:
@echo "$(OK_COLOR)==== $(APP) ====$(NO_COLOR)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(MAKE_COLOR) : %s\n", $$1, $$2}'
.PHONY: clean
clean:
@echo "$(OK_COLOR)[$(APP)] Cleanup$(NO_COLOR)"
@rm $(BUILD_DIR)/*
.PHONY: init
init:
@echo "$(OK_COLOR)[$(APP)] Install requirements$(NO_COLOR)"
@go get -u github.com/golang/glog
@go get -u github.com/Masterminds/rmvcsdir
@go get -u github.com/golang/lint/golint
@go get -u github.com/kisielk/errcheck
@go get -u golang.org/x/tools/cmd/oracle
@go get -u github.com/mitchellh/gox
@go get -u github.com/kardianos/govendor
.PHONY: deps-list
deps-list:
@echo "$(OK_COLOR)[$(APP)] List dependencies$(NO_COLOR)"
@govendor list
.PHONY: deps-update
deps-update:
@echo "$(OK_COLOR)[$(APP)] Update dependencies$(NO_COLOR)"
@govendor update
.PHONY: build
build:
@echo "$(OK_COLOR)[$(APP)] Build $(NO_COLOR)"
@$(GO) build -o $(BUILD_DIR)/nats_exporter .
.PHONY: test
test:
@echo "$(OK_COLOR)[$(APP)] Launch unit tests $(NO_COLOR)"
@govendor test +local
.PHONY: lint
lint:
@$(foreach file,$(SRCS),golint $(file) || exit;)
.PHONY: vet
vet:
@$(foreach file,$(SRCS),$(GO) vet $(file) || exit;)
.PHONY: release-build
release-build:
@echo "$(OK_COLOR)[$(APP)] Create binaries $(NO_COLOR)"
@go get -u github.com/mitchellh/gox
@$(GOX) $(GOX_ARGS) github.com/lovoo/nats_exporter