diff --git a/Makefile b/Makefile index 55a859d..c6ec079 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,40 @@ ################################################################################ -# This Makefile generated by GoMakeGen 2.3.0 using next command: +# This Makefile generated by GoMakeGen 3.0.0 using next command: # gomakegen --mod . # # More info: https://kaos.sh/gomakegen ################################################################################ -export GO111MODULE=on - ifdef VERBOSE ## Print verbose information (Flag) VERBOSE_FLAG = -v endif -COMPAT ?= 1.18 +COMPAT ?= 1.19 MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD) ################################################################################ .DEFAULT_GOAL := help -.PHONY = fmt vet all clean deps update test init vendor gen-fuzz mod-init mod-update mod-download mod-vendor help +.PHONY = fmt vet all install uninstall clean deps update test init vendor gen-fuzz mod-init mod-update mod-download mod-vendor help ################################################################################ all: fz ## Build all binaries fz: - go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" fz.go + @echo "[1/1] Building fz…" + @go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" fz.go install: ## Install all binaries - cp fz /usr/bin/fz + @echo "[1/1] Installing binaries…" + @cp fz /usr/bin/fz uninstall: ## Uninstall all binaries - rm -f /usr/bin/fz + @echo "[1/1] Removing installed binaries…" + @rm -f /usr/bin/fz init: mod-init ## Initialize new module @@ -44,68 +45,83 @@ update: mod-update ## Update dependencies to the latest versions vendor: mod-vendor ## Make vendored copy of dependencies test: ## Run tests + @echo "[1/1] Starting tests…" ifdef COVERAGE_FILE ## Save coverage data into file (String) - go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) ./gofuzz + @go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) ./gofuzz else - go test $(VERBOSE_FLAG) -covermode=count ./gofuzz + @go test $(VERBOSE_FLAG) -covermode=count ./gofuzz endif gen-fuzz: ## Generate archives for fuzz testing - which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build - go-fuzz-build -o gofuzz-fuzz.zip github.com/essentialkaos/fz/gofuzz + @which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build + @echo "[1/1] Generating fuzzing data…" + @go-fuzz-build -o gofuzz-fuzz.zip github.com/essentialkaos/fz/gofuzz mod-init: + @echo "[1/2] Modules initialization…" ifdef MODULE_PATH ## Module path for initialization (String) - go mod init $(MODULE_PATH) + @go mod init $(MODULE_PATH) else - go mod init + @go mod init endif + @echo "[2/2] Dependencies cleanup…" ifdef COMPAT ## Compatible Go version (String) - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif mod-update: + @echo "[1/4] Updating dependencies…" ifdef UPDATE_ALL ## Update all dependencies (Flag) - go get -u $(VERBOSE_FLAG) all + @go get -u $(VERBOSE_FLAG) all else - go get -u $(VERBOSE_FLAG) ./... + @go get -u $(VERBOSE_FLAG) ./... endif + @echo "[2/4] Stripping toolchain info…" + @grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || : + + @echo "[3/4] Dependencies cleanup…" ifdef COMPAT - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif - test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : + @echo "[4/4] Updating vendored dependencies…" + @test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : mod-download: - go mod download + @echo "[1/1] Downloading dependencies…" + @go mod download mod-vendor: - rm -rf vendor && go mod vendor $(VERBOSE_FLAG) + @echo "[1/1] Vendoring dependencies…" + @rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : fmt: ## Format source code with gofmt - find . -name "*.go" -exec gofmt -s -w {} \; + @echo "[1/1] Formatting sources…" + @find . -name "*.go" -exec gofmt -s -w {} \; vet: ## Runs 'go vet' over sources - go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... + @echo "[1/1] Running 'go vet' over sources…" + @go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... clean: ## Remove generated files - rm -f fz + @echo "[1/1] Removing built binaries…" + @rm -f fz 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%-14s\033[0m %s\n", $$1, $$2}' + | 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 //' \ - | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-13s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 3.0.0\033[0m\n' ################################################################################