github.com/mitranim/gg@v0.1.17/makefile (about) 1 MAKEFLAGS := --silent --always-make 2 MAKE_PAR := $(MAKE) -j 128 3 GO_FLAGS := -tags=$(tags) -mod=mod 4 VERB := $(if $(filter $(verb),true), -v,) 5 SHORT := $(if $(filter $(short),true), -short,) 6 PROF := $(if $(filter $(prof),true), -cpuprofile=cpu.prof -memprofile=mem.prof,) 7 TEST_FLAGS := $(GO_FLAGS) -count=1 $(VERB) $(SHORT) $(PROF) 8 TEST := test $(TEST_FLAGS) -timeout=1s -run=$(run) 9 PKG := ./$(or $(pkg),...) 10 BENCH := test $(TEST_FLAGS) -run=- -bench=$(or $(run),.) -benchmem -benchtime=256ms 11 GOW := gow -c -v -e=go,mod,pgsql 12 WATCH := watchexec -r -c -d=0 -n 13 DOC_HOST := localhost:58214 14 OK = echo [$@] ok 15 16 default: test_w 17 18 watch: 19 $(MAKE_PAR) test_w lint_w 20 21 test_w: 22 $(GOW) $(TEST) $(PKG) 23 24 test: 25 go $(TEST) $(PKG) 26 27 bench_w: 28 $(GOW) $(BENCH) $(PKG) 29 30 bench: 31 go $(BENCH) $(PKG) 32 33 lint_w: 34 $(WATCH) -- $(MAKE) lint 35 36 lint: 37 golangci-lint run 38 $(OK) 39 40 vet_w: 41 $(WATCH) -- $(MAKE) vet 42 43 vet: 44 go vet $(GO_FLAGS) $(PKG) 45 $(OK) 46 47 prof: 48 $(MAKE_PAR) prof_cpu prof_mem 49 50 prof_cpu: 51 go tool pprof -web cpu.prof 52 53 prof_mem: 54 go tool pprof -web mem.prof 55 56 # Requires `pkgsite`: 57 # go install golang.org/x/pkgsite/cmd/pkgsite@latest 58 doc: 59 $(or $(shell which open),echo) http://$(DOC_HOST)/github.com/mitranim/gg 60 pkgsite $(if $(GOREPO),-gorepo=$(GOREPO)) -http=$(DOC_HOST) 61 62 prep: 63 $(MAKE_PAR) test lint 64 65 # Example: `make release tag=v0.0.1`. 66 release: prep 67 ifeq ($(tag),) 68 $(error missing tag) 69 endif 70 git pull --rebase 71 git show-ref --tags --quiet "$(tag)" || git tag "$(tag)" 72 git push origin $$(git symbolic-ref --short HEAD) "$(tag)" 73 74 # Assumes MacOS and Homebrew. 75 deps: 76 go install github.com/mitranim/gow@latest 77 brew install -q watchexec golangci-lint