-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
44 lines (32 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
SOURCE_DIRS = cmd pkg
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*")
PLATFORMS = darwin linux
.DEFAULT_GOAL := apb
apb: $(SOURCES) ## Build the samplebroker
go build -i -ldflags="-s -w"
build-all:
$(foreach GOOS, $(PLATFORMS), $(shell export GOOS=$(GOOS); export GOARCH=amd64; go build -v -o apb-$(GOOS)-amd64 -i -ldflags="-s -w"))
install:
go install -ldflags="-s -w"
uninstall: clean
@rm -f ${GOPATH}/bin/apb
lint: ## Run golint
@golint -set_exit_status $(addsuffix /... , $(SOURCE_DIRS))
fmtcheck: ## Check go formatting
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
test: ## Run unit tests
@go test -cover ./cmd/... ./pkg/...
vet: ## Run go vet
@go vet $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS)))
check: fmtcheck vet lint apb test ## Pre-flight checks before creating PR
clean: ## Clean up your working environment
@rm -f apb
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ''
.PHONY: clean lint build fmtcheck test vet help install uninstall