-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
58 lines (46 loc) · 1.79 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
.PHONY: build test clean vet fmt chkfmt
APP = sqly
VERSION = $(shell git describe --tags --abbrev=0)
GO = go
GO_BUILD = $(GO) build
GO_FORMAT = $(GO) fmt
GOFMT = gofmt
GO_LIST = $(GO) list
GO_TEST = $(GO) test -v
GO_TOOL = $(GO) tool
GO_VET = $(GO) vet
GO_DEP = $(GO) mod
GOOS = ""
GOARCH = ""
GO_PKGROOT = ./...
GO_PACKAGES = $(shell $(GO_LIST) $(GO_PKGROOT))
GO_LDFLAGS = -ldflags '-X github.com/nao1215/sqly/config.Version=${VERSION}'
build: ## Build binary
env GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD) $(GO_LDFLAGS) -o $(APP) main.go
clean: ## Clean project
-rm -rf $(APP) cover.out cover.html
test: ## Start test
env GOOS=$(GOOS) $(GO_TEST) -cover $(GO_PKGROOT) -coverpkg=./... -coverprofile=cover.out
$(GO_TOOL) cover -html=cover.out -o cover.html
bench: ## Start benchmark
env GOOS=$(GOOS) go test -bench=BenchmarkImport100000Records -benchmem
coverage-tree: test ## Generate coverage tree
go-cover-treemap -statements -coverprofile cover.out > doc/img/cover-tree.svg
changelog: ## Generate changelog
ghch --format markdown > CHANGELOG.md
generate: ## Generate code from templates
$(GO) generate ./...
tools: ## Install dependency tools
$(GO_INSTALL) github.com/Songmu/ghch/cmd/ghch@latest
$(GO_INSTALL) github.com/nao1215/hottest@latest
$(GO_INSTALL) github.com/google/wire/cmd/wire@latest
$(GO_INSTALL) github.com/charmbracelet/vhs@latest
$(GO_INSTALL) github.com/nikolaydubina/go-cover-treemap@latest
vet: ## Start go vet
$(GO_VET) $(GO_PACKAGES)
fmt: ## Format go source code
$(GO_FORMAT) $(GO_PKGROOT)
.DEFAULT_GOAL := help
help:
@grep -E '^[0-9a-zA-Z_-]+[[:blank:]]*:.*?## .*$$' $(MAKEFILE_LIST) | sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[1;32m%-15s\033[0m %s\n", $$1, $$2}'