-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (100 loc) · 4.29 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
################################################################################
# This Makefile generated by GoMakeGen 3.2.3 using next command:
# gomakegen --mod --cgo .
#
# More info: https://kaos.sh/gomakegen
################################################################################
ifdef VERBOSE ## Print verbose information (Flag)
VERBOSE_FLAG = -v
endif
ifdef PROXY ## Force proxy usage for downloading dependencies (Flag)
export GOPROXY=https://proxy.golang.org/cached-only,direct
endif
export CGO_ENABLED=1
MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)
################################################################################
.DEFAULT_GOAL := help
.PHONY = fmt vet all install uninstall clean deps update test init vendor mod-init mod-update mod-download mod-vendor help
################################################################################
all: rep ## Build all binaries
rep:
@echo "[36;1mBuilding rep…[0m"
@go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" rep.go
install: ## Install all binaries
@echo "[36;1mInstalling binaries…[0m"
@cp rep /usr/bin/rep
uninstall: ## Uninstall all binaries
@echo "[36;1mRemoving installed binaries…[0m"
@rm -f /usr/bin/rep
init: mod-init ## Initialize new module
deps: mod-download ## Download dependencies
update: mod-update ## Update dependencies to the latest versions
vendor: mod-vendor ## Make vendored copy of dependencies
test: ## Run tests
@echo "[36;1mStarting tests…[0m"
ifdef COVERAGE_FILE ## Save coverage data into file (String)
@go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) ./cli/logger ./cli/query ./repo ./repo/data ./repo/groups ./repo/helpers ./repo/index ./repo/meta ./repo/rpm ./repo/search ./repo/sign ./repo/sign/keygen ./repo/storage/fs ./repo/storage/utils
else
@go test $(VERBOSE_FLAG) -covermode=count ./...
endif
mod-init:
@echo "[37m[1/3][0m [36;1mModules initialization…[0m"
@rm -f go.mod go.sum
ifdef MODULE_PATH ## Module path for initialization (String)
@go mod init $(MODULE_PATH)
else
@go mod init
endif
@echo "[37m[2/3][0m [36;1mDependencies cleanup…[0m"
ifdef COMPAT ## Compatible Go version (String)
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
else
@go mod tidy $(VERBOSE_FLAG)
endif
@echo "[37m[3/3][0m [36;1mStripping toolchain info…[0m"
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :
mod-update:
@echo "[37m[1/4][0m [36;1mUpdating dependencies…[0m"
ifdef UPDATE_ALL ## Update all dependencies (Flag)
@go get -u $(VERBOSE_FLAG) all
else
@go get -u $(VERBOSE_FLAG) ./...
endif
@echo "[37m[2/4][0m [36;1mStripping toolchain info…[0m"
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :
@echo "[37m[3/4][0m [36;1mDependencies cleanup…[0m"
ifdef COMPAT
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
else
@go mod tidy $(VERBOSE_FLAG)
endif
@echo "[37m[4/4][0m [36;1mUpdating vendored dependencies…[0m"
@test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
mod-download:
@echo "[36;1mDownloading dependencies…[0m"
@go mod download
mod-vendor:
@echo "[36;1mVendoring dependencies…[0m"
@rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
fmt: ## Format source code with gofmt
@echo "[36;1mFormatting sources…[0m"
@find . -name "*.go" -exec gofmt -s -w {} \;
vet: ## Runs 'go vet' over sources
@echo "[36;1mRunning 'go vet' over sources…[0m"
@go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...
clean: ## Remove generated files
@echo "[36;1mRemoving built binaries…[0m"
@rm -f rep
help: ## Show this info
@echo -e '\n\033[1mTargets:\033[0m\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-9s\033[0m %s\n", $$1, $$2}'
@echo -e '\n\033[1mVariables:\033[0m\n'
@grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \
| sed 's/ifdef //' \
| sort -h \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-13s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 3.2.3\033[0m\n'
################################################################################