forked from openimsdk/open-im-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
149 lines (114 loc) · 3.61 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
143
144
145
146
147
148
149
# TODO: 参考我对 horizon 的 Makefile 设计:
# TODO: https://github.com/horizoncd/horizon/pull/141
# TODO: 设计稿:代写~
# TODO:请在 issue 关闭之前不要使用 Makefile 中的 targe(尤其是重构前)
# ==============================================================================
# define the default goal
#
.DEFAULT_GOAL := help
.PHONY: all
all: tidy gen add-copyright format lint cover build
# ==============================================================================
# Build set
ROOT_PACKAGE=github.com/OpenIMSDK/Open-IM-Server
# TODO: This is version control for the future
VERSION_PACKAGE=github.com/OpenIMSDK/Open-IM-Server/pkg/version
# ==============================================================================
# Includes
include script/make-rules/common.mk # make sure include common.mk at the first include line
include script/make-rules/golang.mk
include script/make-rules/image.mk
include script/make-rules/copyright.mk
include script/make-rules/gen.mk
include script/make-rules/dependencies.mk
include script/make-rules/tools.mk
# ==============================================================================
# Usage
define USAGE_OPTIONS
Options:
DEBUG Whether or not to generate debug symbols. Default is 0.
BINS Binaries to build. Default is all binaries under cmd.
This option is available when using: make {build}(.multiarch)
Example: make build BINS="open_im_api open_im_cms_api"
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
Example: make build.multiarch PLATFORMS="linux_arm64 linux_amd64"
V Set to 1 enable verbose build. Default is 0.
endef
export USAGE_OPTIONS
# ==============================================================================
# Targets
## build: Build binaries by default
.PHONY: build
build:
@$(MAKE) go.build
## tidy: tidy go.mod
.PHONY: tidy
tidy:
@$(GO) mod tidy
## vendor: vendor go.mod
.PHONY: vendor
vendor:
@$(GO) mod vendor
## fmt: Run go fmt against code.
.PHONY: fmt
fmt:
@$(GO) fmt ./...
## vet: Run go vet against code.
.PHONY: vet
vet:
@$(GO) vet ./...
## lint: Check syntax and styling of go sources.
.PHONY: lint
lint:
@$(MAKE) go.lint
## style: code style -> fmt,vet,lint
.PHONY: style
style: fmt vet lint
## format: Gofmt (reformat) package sources (exclude vendor dir if existed).
.PHONY: format
format:
@$(MAKE) go.format
## test: Run unit test.
.PHONY: test
test:
@$(MAKE) go.test
## cover: Run unit test and get test coverage.
.PHONY: cover
cover:
@$(MAKE) go.test.cover
## updates: Check for updates to go.mod dependencies
.PHONY: updates
@$(MAKE) go.updates
## imports: task to automatically handle import packages in Go files using goimports tool
.PHONY: imports
imports:
@$(MAKE) go.imports
## clean: Remove all files that are created by building.
.PHONY: clean
clean:
@$(MAKE) go.clean
## tools: Install dependent tools.
.PHONY: tools
tools:
@$(MAKE) tools.install
## gen: Generate all necessary files.
.PHONY: gen
gen:
@$(MAKE) gen.run
## verify-copyright: Verify the license headers for all files.
.PHONY: verify-copyright
verify-copyright:
@$(MAKE) copyright.verify
## add-copyright: Add copyright ensure source code files have license headers.
.PHONY: add-copyright
add-copyright:
@$(MAKE) copyright.add
## help: Show this help info.
.PHONY: help
help: Makefile
$(call makehelp)
## all-help: Show all help details info.
.PHONY: help-all
help-all: go.help copyright.help tools.help image.help help
$(call makeallhelp)