|
1 | 1 | ################################################################################
|
2 | 2 |
|
3 |
| -# This Makefile generated by GoMakeGen 1.5.1 using next command: |
| 3 | +# This Makefile generated by GoMakeGen 3.0.2 using next command: |
4 | 4 | # gomakegen --mod .
|
5 | 5 | #
|
6 | 6 | # More info: https://kaos.sh/gomakegen
|
7 | 7 |
|
8 | 8 | ################################################################################
|
9 | 9 |
|
10 |
| -export GO111MODULE=on |
| 10 | +ifdef VERBOSE ## Print verbose information (Flag) |
| 11 | +VERBOSE_FLAG = -v |
| 12 | +endif |
11 | 13 |
|
12 |
| -.DEFAULT_GOAL := help |
13 |
| -.PHONY = fmt vet deps deps-test test gen-fuzz mod-init mod-update mod-vendor help |
| 14 | +COMPAT ?= 1.19 |
| 15 | +MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) |
| 16 | +GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD) |
14 | 17 |
|
15 | 18 | ################################################################################
|
16 | 19 |
|
17 |
| -deps: mod-update ## Download dependencies |
| 20 | +.DEFAULT_GOAL := help |
| 21 | +.PHONY = fmt vet deps update test init vendor gen-fuzz mod-init mod-update mod-download mod-vendor help |
18 | 22 |
|
19 |
| -deps-test: deps ## Download dependencies for tests |
| 23 | +################################################################################ |
20 | 24 |
|
21 |
| -test: ## Run tests |
22 |
| - go test -covermode=count . |
| 25 | +init: mod-init ## Initialize new module |
23 | 26 |
|
24 |
| -gen-fuzz: ## Generate archives for fuzz testing |
25 |
| - which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build |
26 |
| - go-fuzz-build -o fuzz.zip github.com/essentialkaos/go-zabbix |
| 27 | +deps: mod-download ## Download dependencies |
| 28 | + |
| 29 | +update: mod-update ## Update dependencies to the latest versions |
27 | 30 |
|
28 |
| -mod-init: ## Initialize new module |
29 |
| - go mod init |
30 |
| - go mod tidy |
| 31 | +vendor: mod-vendor ## Make vendored copy of dependencies |
31 | 32 |
|
32 |
| -mod-update: ## Download modules to local cache |
33 |
| - go mod download |
| 33 | +test: ## Run tests |
| 34 | + @echo "[36;1mStarting tests…[0m" |
| 35 | +ifdef COVERAGE_FILE ## Save coverage data into file (String) |
| 36 | + @go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) . |
| 37 | +else |
| 38 | + @go test $(VERBOSE_FLAG) -covermode=count . |
| 39 | +endif |
34 | 40 |
|
35 |
| -mod-vendor: ## Make vendored copy of dependencies |
36 |
| - go mod vendor |
| 41 | +gen-fuzz: ## Generate archives for fuzz testing |
| 42 | + @which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build |
| 43 | + @echo "[36;1mGenerating fuzzing data…[0m" |
| 44 | + @go-fuzz-build -o fuzz.zip github.com/essentialkaos/go-zabbix |
| 45 | + |
| 46 | +mod-init: |
| 47 | + @echo "[37m[1/2][0m [36;1mModules initialization…[0m" |
| 48 | +ifdef MODULE_PATH ## Module path for initialization (String) |
| 49 | + @go mod init $(MODULE_PATH) |
| 50 | +else |
| 51 | + @go mod init |
| 52 | +endif |
| 53 | + |
| 54 | + @echo "[37m[2/2][0m [36;1mDependencies cleanup…[0m" |
| 55 | +ifdef COMPAT ## Compatible Go version (String) |
| 56 | + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) |
| 57 | +else |
| 58 | + @go mod tidy $(VERBOSE_FLAG) |
| 59 | +endif |
| 60 | + |
| 61 | +mod-update: |
| 62 | + @echo "[37m[1/4][0m [36;1mUpdating dependencies…[0m" |
| 63 | +ifdef UPDATE_ALL ## Update all dependencies (Flag) |
| 64 | + @go get -u $(VERBOSE_FLAG) all |
| 65 | +else |
| 66 | + @go get -u $(VERBOSE_FLAG) ./... |
| 67 | +endif |
| 68 | + |
| 69 | + @echo "[37m[2/4][0m [36;1mStripping toolchain info…[0m" |
| 70 | + @grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || : |
| 71 | + |
| 72 | + @echo "[37m[3/4][0m [36;1mDependencies cleanup…[0m" |
| 73 | +ifdef COMPAT |
| 74 | + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) |
| 75 | +else |
| 76 | + @go mod tidy $(VERBOSE_FLAG) |
| 77 | +endif |
| 78 | + |
| 79 | + @echo "[37m[4/4][0m [36;1mUpdating vendored dependencies…[0m" |
| 80 | + @test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : |
| 81 | + |
| 82 | +mod-download: |
| 83 | + @echo "[36;1mDownloading dependencies…[0m" |
| 84 | + @go mod download |
| 85 | + |
| 86 | +mod-vendor: |
| 87 | + @echo "[36;1mVendoring dependencies…[0m" |
| 88 | + @rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : |
37 | 89 |
|
38 | 90 | fmt: ## Format source code with gofmt
|
39 |
| - find . -name "*.go" -exec gofmt -s -w {} \; |
| 91 | + @echo "[36;1mFormatting sources…[0m" |
| 92 | + @find . -name "*.go" -exec gofmt -s -w {} \; |
40 | 93 |
|
41 |
| -vet: ## Runs go vet over sources |
42 |
| - go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... |
| 94 | +vet: ## Runs 'go vet' over sources |
| 95 | + @echo "[36;1mRunning 'go vet' over sources…[0m" |
| 96 | + @go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... |
43 | 97 |
|
44 | 98 | help: ## Show this info
|
45 |
| - @echo -e '\n\033[1mSupported targets:\033[0m\n' |
| 99 | + @echo -e '\n\033[1mTargets:\033[0m\n' |
46 | 100 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
|
47 |
| - | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}' |
| 101 | + | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-8s\033[0m %s\n", $$1, $$2}' |
| 102 | + @echo -e '\n\033[1mVariables:\033[0m\n' |
| 103 | + @grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \ |
| 104 | + | sed 's/ifdef //' \ |
| 105 | + | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-13s\033[0m %s\n", $$1, $$2}' |
48 | 106 | @echo -e ''
|
49 |
| - @echo -e '\033[90mGenerated by GoMakeGen 1.5.1\033[0m\n' |
| 107 | + @echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n' |
50 | 108 |
|
51 | 109 | ################################################################################
|
0 commit comments