-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (52 loc) · 1.63 KB
/
Copy pathMakefile
File metadata and controls
65 lines (52 loc) · 1.63 KB
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
export GIT_COMMIT ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || echo unknown)
export VERSION ?= ${GIT_COMMIT}
export LD_FLAGS = -X "main.commit=$(GIT_COMMIT)" -X "main.version=$(VERSION)" -X "main.date=$(shell date)"
export GOBIN = $(abspath .)/.tools/bin
export PATH := $(GOBIN):$(abspath .)/bin:$(PATH)
export CGO_ENABLED=0
export V = 0
export Q = $(if $(filter 1,$V),,@)
export M = $(shell printf "\033[34;1m▶\033[0m")
export CC = go build -ldflags '$(LD_FLAGS)'
.PHONY: help
help:
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
.PHONY: deps
deps:
$(info $(M) fetching deps …)
$Q go get -d -v ./...
$Q go mod tidy
.PHONY: install-deptools
install-deptools: deps ## install dependent go tools
$(info $(M) installing necessary tools …)
$Q ./scripts/install_tools_check.sh
.PHONY: gen
gen:
@go generate ./internal/templates/grpcwithgw
# Build servicebuilder binary
.PHONY: build
build: install-deptools gen fmt vet
$(info $(M) building …)
$Q $(CC) -o bin/servicebuilder ./
# Run go fmt against code
.PHONY: fmt
fmt:
$(info $(M) formatting …)
$Q goimports -w -local github.com/cnative/servicebuilder ./cmd ./internal
# Run go vet against code
.PHONY: vet
vet: ## run go vet on all source files
$(info $(M) vetting …)
$Q go vet ./...
.PHONY: lint
lint: ## run golint
$(info $(M) linting …)
$Q ./.tools/bin/golangci-lint --verbose run ./... --timeout=5m
# Run tests
.PHONY: test
test: fmt vet
go test ./... -coverprofile cover.out
.PHONY: clean
clean:
@rm -rf bin dist
@rm -rf test/tests.* test/coverage.*