forked from SAP/project-kb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (58 loc) · 1.82 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
$(eval VERSION = $(shell head VERSION))
$(eval GIT_COMMIT = $(shell git rev-parse HEAD))
$(eval NOW = $(shell date))
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=kaybee
LDFLAGS=-ldflags='-X "github.com/sap/project-kb/kaybee/cmd.buildDate=$(NOW)" -X "github.com/sap/project-kb/kaybee/cmd.buildCommitID=$(GIT_COMMIT)" -X "github.com/sap/project-kb/kaybee/cmd.version=$(VERSION)"'
BINARY_UNIX=$(BINARY_NAME)-$(VERSION)_linux-amd64
BINARY_WINDOWS=$(BINARY_NAME)-$(VERSION)_win-amd64
BINARY_MACOS=$(BINARY_NAME)-$(VERSION)_darwin-amd64
all: env lint vet test build #ui
env:
$(GOCMD) env -w GO111MODULE=auto
build: env pkged.go fmt
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) -v
pkged.go: internal/tasks/data/default_config.yaml
pkger -o kaybee
# ui:
# $(MAKE) --directory=ui
check: lint vet test
test: pkged.go
$(GOTEST) -failfast -coverprofile=coverage.out ./...
coverage: test
go tool cover -html=coverage.out
clean:
$(GOCLEAN)
@rm -f $(BINARY_NAME)
@rm -f $(BINARY_UNIX)
@rm -f $(BINARY_MACOS)
@rm coverage.out
@rm -fr dist
run:
$(GOBUILD) -o $(BINARY_NAME) -v ./...
./$(BINARY_NAME)
vet: fmt
$(GOCMD) vet ./...
doc:
$(GOCMD) doc ./...
fmt:
$(GOCMD) fmt ./...
lint: vet
@golint ./...
security:
@gosec -include=G101,G201,G202,G203,G301,G302,G303,G305,G306,G401 ./...
@echo "[OK] Go security check was completed!"
# Cross compilation
build-linux: pkged.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_UNIX) -v
build-win: pkged.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_WINDOWS) -v
build-macos: pkged.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o dist/$(BINARY_MACOS) -v
build-all: pkged.go build-win build-macos build-linux
.PHONY: build-all