forked from lindb/lindb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (89 loc) · 4.1 KB
/
Copy pathMakefile
File metadata and controls
118 lines (89 loc) · 4.1 KB
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
.PHONY: help build test deps generate clean
# use the latest git tag as release-version
GIT_TAG_NAME=$(shell git tag --sort=-creatordate|head -n 1)
BUILD_TIME=$(shell date "+%Y-%m-%dT%H:%M:%S%z")
ifeq ($(GIT_TAG_NAME),)
GIT_TAG_NAME := "unknown"
endif
LD_FLAGS=-ldflags="-s -w -X github.com/lindb/lindb/config.Version=$(GIT_TAG_NAME) -X github.com/lindb/lindb/config.BuildTime=$(BUILD_TIME)"
# Ref: https://gist.github.com/prwhite/8168133
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \
/^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
run: ## run local standalone cluster for demo/debug
go run github.com/lindb/lindb/cmd/lind standalone run --pprof --doc
build-frontend: ## build frontend
cd web/ && make web_build
GOARCH = amd64
build: clean-build build-frontend build-lind ## Build executable files.
build-all: clean-frontend-build build-frontend clean-build build-lind ## Build executable files with front-end files inside.
build-lind: ## build lindb binary
env GOOS=darwin GOARCH=$(GOARCH) go build -o 'bin/lind-darwin' $(LD_FLAGS) ./cmd/lind
env GOOS=linux GOARCH=$(GOARCH) go build -o 'bin/lind-linux' $(LD_FLAGS) ./cmd/lind
env GOOS=windows GOARCH=$(GOARCH) go build -o 'bin/lind-windows.exe' $(LD_FLAGS) ./cmd/lind
env GOOS=darwin GOARCH=$(GOARCH) go build -o 'bin/lindcli-darwin' $(LD_FLAGS) ./cmd/cli
env GOOS=linux GOARCH=$(GOARCH) go build -o 'bin/lindcli-linux' $(LD_FLAGS) ./cmd/cli
env GOOS=windows GOARCH=$(GOARCH) go build -o 'bin/lindcli-windows.exe' $(LD_FLAGS) ./cmd/cli
deploy: build-frontend ## deploy release packages
sh deploy.sh
.PHONY: docker-build
docker-build: ## build docker image
docker build -t wangguohao/lindb:$(GIT_TAG_NAME) --build-arg LD_FLAGS=${LD_FLAGS} .
.PHONY: docker-push
docker-push: ## push docker image
docker push wangguohao/lindb:$(GIT_TAG_NAME)
GOMOCK_VERSION = "v1.5.0"
gomock: ## go generate mock file.
go install "github.com/golang/mock/mockgen@$(GOMOCK_VERSION)"
go list ./... |grep -v '/gomock' | xargs go generate -v
header: ## check and add license header.
sh scripts/addlicense.sh
import: ## opt go imports format.
sh scripts/imports.sh
lint: ## run lint
go install "github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0"
golangci-lint run ./...
api-doc: ## generate api document
go install "github.com/swaggo/swag/cmd/swag@v1.8.7"
swag init -g pkg/http/doc.go
test-without-lint: ## Run test without lint
go install "github.com/rakyll/gotest@v0.0.6"
GIN_MODE=release
LOG_LEVEL=fatal ## disable log for test
gotest -v -race -coverprofile=coverage.out -covermode=atomic ./...
test: header lint test-without-lint ## Run test cases.
e2e-test:
go install "github.com/rakyll/gotest@v0.0.6"
GIN_MODE=release
LOG_LEVEL=fatal ## disable log for test
gotest -v --tags=integration -race -coverprofile=coverage.out -covermode=atomic ./e2e/...
e2e: header e2e-test
deps: ## Update vendor.
go mod verify
go mod tidy -v
generate: ## generate pb/tmpl file.
# go get github.com/benbjohnson/tmpl
go install github.com/benbjohnson/tmpl@latest
# brew install flatbuffers
sh ./proto/generate.sh
cd tsdb/template && sh generate_tmpl.sh
gen-sql-grammar: ## generate lin query language gen-sql-grammar
# need install antrl4-tools
# https://github.com/antlr/antlr4/blob/master/doc/getting-started.md
antlr4 -Dlanguage=Go -listener -visitor -package grammar ./sql/grammar/SQL.g4
key-words: ## print all key words for lin query language
go run github.com/lindb/lindb/cmd/tools keywords
clean-mock: ## remove all mock files
find ./ -name "*_mock.go" | xargs rm
clean-build:
rm -rf bin/*
clean-frontend-build:
cd web/ && make web_clean
clean-tmp: ## clean up tmp and test out files
find . -type f -name '*.out' -exec rm -f {} +
find . -type f -name '.DS_Store' -exec rm -f {} +
find . -type f -name '*.test' -exec rm -f {} +
find . -type f -name '*.prof' -exec rm -f {} +
find . -type s -name 'localhost:*' -exec rm -f {} +
find . -type s -name '127.0.0.1:*' -exec rm -f {} +
clean: clean-mock clean-tmp clean-build clean-frontend-build ## Clean up useless files.