forked from matrixorigin/matrixone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
142 lines (125 loc) · 5.59 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# This Makefile is to build MatrixOne
BIN_NAME := mo-server
BUILD_CFG := gen_config
UNAME_S := $(shell uname -s)
GO_VERSION=$(shell go version)
BRANCH_NAME=$(shell git rev-parse --abbrev-ref HEAD)
LAST_COMMIT_ID=$(shell git rev-parse HEAD)
BUILD_TIME=$(shell date)
MO_Version=$(shell git describe --abbrev=0 --tags)
TARGET_OS ?=
TARGET_ARCH ?=
BVT_BRANCH ?= master
# generate files generated from .template and needs to delete when clean
GENERATE_OVERLOAD_LOGIC := ./pkg/sql/colexec/extend/overload/and.go ./pkg/sql/colexec/extend/overload/or.go
GENERATE_OVERLOAD_MATH := ./pkg/sql/colexec/extend/overload/div.go ./pkg/sql/colexec/extend/overload/minus.go ./pkg/sql/colexec/extend/overload/mod.go ./pkg/sql/colexec/extend/overload/plus.go ./pkg/sql/colexec/extend/overload/mult.go
GENERATE_OVERLOAD_COMPARE := ./pkg/sql/colexec/extend/overload/eq.go ./pkg/sql/colexec/extend/overload/ge.go ./pkg/sql/colexec/extend/overload/ne.go /pkg/sql/colexec/extend/overload/ge.go ./pkg/sql/colexec/extend/overload/gt.go ./pkg/sql/colexec/extend/overload/le.go ./pkg/sql/colexec/extend/overload/lt.go
GENERATE_OVERLOAD_OTHERS := ./pkg/sql/colexec/extend/overload/like.go ./pkg/sql/colexec/extend/overload/cast.go
GENERATE_OVERLOAD_UNARYS := ./pkg/sql/colexec/extend/overload/unaryops.go
# Creating build config
.PHONY: config
config: cmd/generate-config/main.go cmd/generate-config/config_template.go cmd/generate-config/system_vars_def.toml
$(info [Create build config])
@go mod tidy
@go build -o $(BUILD_CFG) cmd/generate-config/main.go cmd/generate-config/config_template.go
@./$(BUILD_CFG) cmd/generate-config/system_vars_def.toml
@mv -f cmd/generate-config/system_vars_config.toml .
@mv -f cmd/generate-config/system_vars.go pkg/config
@mv -f cmd/generate-config/system_vars_test.go pkg/config
# Building mo-server binary
.PHONY: build
build: cmd/db-server/$(wildcard *.go)
@go generate ./pkg/sql/colexec/extend/overload
ifeq ($(TARGET_OS)$(TARGET_ARCH), )
$(info [Build binary])
@go build -ldflags="-X 'main.GoVersion=$(GO_VERSION)' -X 'main.BranchName=$(BRANCH_NAME)' -X 'main.LastCommitId=$(LAST_COMMIT_ID)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.MoVersion=$(MO_Version)'" -o $(BIN_NAME) ./cmd/db-server/
else ifneq ($(TARGET_OS), )
ifneq ($(TARGET_ARCH), )
$(info [Cross Build binary])
$(info $(TARGET_OS))
$(info $(TARGET_ARCH))
@CGO_ENABLED=1 GOOS=$(TARGET_OS) GOARCH=$(TARGET_ARCH) go build -ldflags="-X 'main.GoVersion=$(GO_VERSION)' -X 'main.BranchName=$(BRANCH_NAME)' -X 'main.LastCommitId=$(LAST_COMMIT_ID)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.MoVersion=$(MO_Version)'" -o $(BIN_NAME) ./cmd/db-server/
else
$(info [Cross Build binary])
$(info $(TARGET_OS))
@CGO_ENABLED=1 GOOS=$(TARGET_OS) go build -ldflags="-X 'main.GoVersion=$(GO_VERSION)' -X 'main.BranchName=$(BRANCH_NAME)' -X 'main.LastCommitId=$(LAST_COMMIT_ID)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.MoVersion=$(MO_Version)'" -o $(BIN_NAME) ./cmd/db-server/
endif
endif
# Building mo-server binary for debugging, it uses the latest MatrixCube from master.
.PHONY: debug
debug: cmd/db-server/$(wildcard *.go)
@go generate ./pkg/sql/colexec/extend/overload
$(info [Build binary for debug])
go get github.com/matrixorigin/matrixcube
go mod tidy
go build -ldflags="-X 'main.GoVersion=$(GO_VERSION)' -X 'main.BranchName=$(BRANCH_NAME)' -X 'main.LastCommitId=$(LAST_COMMIT_ID)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.MoVersion=$(MO_Version)'" -o $(BIN_NAME) ./cmd/db-server/
# Run Static Code Analysis
.PHONY: sca
sca:
@go generate ./pkg/sql/colexec/extend/overload
$(info [Static code analysis])
@cd optools && ./run_ut.sh SCA
# Excluding frontend test cases temporarily
# Argument SKIP_TEST to skip a specific go test
.PHONY: ut
ut:
@go generate ./pkg/sql/colexec/extend/overload
$(info [Unit testing])
ifeq ($(UNAME_S),Darwin)
@cd optools && ./run_ut.sh UT $(SKIP_TEST)
else
@cd optools && timeout 30m ./run_ut.sh UT $(SKIP_TEST)
endif
# Running build verification tests
.PHONY: bvt
bvt: mo-server
$(info [Build verification testing])
ifeq ($(UNAME_S),Darwin)
@cd optools; ./run_bvt.sh BVT False $(BVT_BRANCH)
else
@cd optools; timeout 30m ./run_bvt.sh BVT False $(BVT_BRANCH)
endif
# Tear down
.PHONY: clean
clean:
$(info [Clean up])
$(info Clean go test cache)
@go clean -testcache
@rm -f $(GENERATE_OVERLOAD_LOGIC)
@rm -f $(GENERATE_OVERLOAD_MATH)
@rm -f $(GENERATE_OVERLOAD_COMPARE)
@rm -f $(GENERATE_OVERLOAD_OTHERS)
@rm -f $(GENERATE_OVERLOAD_UNARYS)
ifneq ($(wildcard $(BIN_NAME)),)
$(info Remove file $(BIN_NAME))
@rm -f $(BIN_NAME)
endif
ifneq ($(wildcard $(BUILD_CFG)),)
$(info Remove file $(BUILD_CFG))
@rm -f $(BUILD_CFG)
endif
###############################################################################
# static checks
###############################################################################
.PHONY: install-static-check-tools
install-static-check-tools:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $(GOROOT)/bin v1.45.2
# TODO: switch to the following two lists after some major cleanups
# TODO: switch to a more recent version of golangci-lint, currently on v1.23.8
# PKGS=$(shell go list ./...)
# DIRS=$(subst $(PKGNAME), ,$(subst $(PKGNAME)/, ,$(CHECKED_PKGS))) .
DIRS=pkg/... \
cmd/...
EXTRA_LINTERS=-E misspell -E exportloopref -E rowserrcheck -E depguard -E unconvert \
-E prealloc -E gofmt -E stylecheck
.PHONY: static-check
static-check:
@for p in $(DIRS); do \
golangci-lint run $(EXTRA_LINTERS) $$p; \
done;
.PHONY: install-molint
install-molint:
@go install github.com/matrixorigin/linter/cmd/molint@latest
.PHONY: molint
molint:
@go vet -vettool=$(shell which molint) ./...