forked from mosn/layotto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
308 lines (261 loc) · 13.1 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# Copyright 2021 Layotto Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Layotto commands 👀:
# A fast and efficient cloud native application runtime 🚀.
# Commands below are used in Development 💻 and GitHub workflow 🌊.
# Usage: make <COMMANDS> <ARGS> ...
# COMMANDS:
# build Build layotto for host platform.
# build.multiarch Build layotto for multiple platforms. See option PLATFORMS.
# image Build docker images for host arch.
# image.multiarch Build docker images for multiple platforms. See option PLATFORMS.
# push Push docker images to registry.
# push.multiarch Push docker images for multiple platforms to registry.
# app Build app docker images for host arch. [`/docker/app` contains apps dockerfiles]
# app.multiarch Build app docker images for multiple platforms. See option PLATFORMS.
# wasm Build layotto wasm for linux arm64 platform.
# wasm.multiarch Build layotto wasm for multiple platform.
# wasm.image Build layotto wasm image for multiple platform.
# wasm.image.push Push layotto wasm image for multiple platform.
# check Run all go checks of code sources.
# check.lint Run go syntax and styling of go sources.
# check.unit Run go unit test.
# check.style Run go style test.
# style.coverage Run coverage analysis.
# style.deadlink Run deadlink check test.
# style.quickstart Run quickstart check test.
# integrate.wasm Run integration test with wasm.
# integrate.runtime Run integration test with runtime.
# format Format layotto go codes style with gofmt and goimports.
# clean Remove all files that are created by building.
# all Run format codes, check codes, build Layotto codes for host platform with one command
# help Show this help info.
# ARGS:
# BINS The binaries to build. Default is all of cmd.
# This option is available when using: make build/build.multiarch
# Example: make build BINS="layotto_multiple_api layotto"
# IMAGES Backend images to make. Default is all of cmds.
# This option is available when using: make image/image.multiarch/push/push.multiarch
# Example: make image.multiarch IMAGES="layotto_multiple_api layotto"
# PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64.
# This option is available when using: make build.multiarch/image.multiarch/push.multiarch
# Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64"
# Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64
SHELL := /bin/bash
# ==============================================================================
# ROOT Options:
# ==============================================================================
ROOT_PACKAGE=mosn.io/layotto
# ==============================================================================
# Includes:
# ==============================================================================
include make/common.mk
include make/golang.mk
include make/image.mk
include make/wasm.mk
include make/ci.mk
include make/proto.mk
# ==============================================================================
# Targets:
# ==============================================================================
# ==============================================================================
## build: Build layotto for host platform.
# ==============================================================================
.PHONY: build
build:
@$(MAKE) go.build
# ==============================================================================
## build.multiarch: Build layotto for multiple platforms. See option PLATFORMS.
# ==============================================================================
.PHONY: build.multiarch
build.multiarch:
@$(MAKE) go.build.multiarch
# ==============================================================================
## image: Build docker images for host arch.
# ==============================================================================
.PHONY: image
image:
@$(MAKE) image.build
# ==============================================================================
## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS.
# ==============================================================================
.PHONY: image.multiarch
image.multiarch:
@$(MAKE) image.build.multiarch
# ==============================================================================
## push: Push docker images to registry.
# ==============================================================================
.PHONY: push
push:
@$(MAKE) image.push
# ==============================================================================
## push.multiarch: Push docker images for multiple platforms to registry.
# ==============================================================================
.PHONY: push.multiarch
push.multiarch:
@$(MAKE) image.push.multiarch
# ==============================================================================
## app: Build app docker images for host arch. [`/docker/app` contains apps dockerfiles]
# ==============================================================================
.PHONY: app
app:
@$(MAKE) app.image
# ==============================================================================
## app.multiarch: Build app docker images for multiple platforms. See option PLATFORMS.
# ==============================================================================
.PHONY: app.multiarch
app.multiarch:
@$(MAKE) app.image.multiarch
# ==============================================================================
## wasm: Build layotto wasm for linux arm64 platform.
# ==============================================================================
.PHONY: wasm
wasm:
@$(MAKE) go.wasm
# ==============================================================================
## wasm.multiarch: Build layotto wasm for multiple platform.
# ==============================================================================
.PHONY: wasm.multiarch
wasm.multiarch:
@$(MAKE) go.wasm.multiarch
# ==============================================================================
## wasm.image: Build layotto wasm image for multiple platform.
# ==============================================================================
.PHONY: wasm.image
wasm.image:
@$(MAKE) go.wasm.image
# ==============================================================================
## wasm.image.push: Push layotto wasm image for multiple platform.
# ==============================================================================
.PHONY: wasm.image.push
wasm.image.push:
@$(MAKE) go.wasm.image.push
# ==============================================================================
## check: Run all go checks of code sources.
# ==============================================================================
.PHONY: check
check: check.style check.unit check.lint
# ==============================================================================
## check.lint: Run go syntax and styling of go sources.
# ==============================================================================
.PHONY: check.lint
check.lint:
@$(MAKE) go.lint
# ==============================================================================
## check.unit: Run go unit test.
# ==============================================================================
.PHONY: check.unit
check.unit:
@$(MAKE) go.test
# ==============================================================================
## check.style: Run go style test.
# ==============================================================================
.PHONY: check.style
check.style:
@$(MAKE) go.style
# ==============================================================================
## style.coverage: Run coverage analysis.
# ==============================================================================
.PHONY: style.coverage
style.coverage:
@$(MAKE) checker.coverage
# ==============================================================================
## style.deadlink: Run deadlink check test.
# ==============================================================================
.PHONY: style.deadlink
style.deadlink:
@$(MAKE) checker.deadlink
# ==============================================================================
## style.quickstart: Run quickstart check test.
# ==============================================================================
.PHONY: style.quickstart
style.quickstart:
@$(MAKE) checker.quickstart
# ==============================================================================
## license: Add license headers for code files.
# ==============================================================================
.PHONY: license
license:
@$(MAKE) checker.license.fix
# ==============================================================================
## integrate.wasm: Run integration test with wasm.
# ==============================================================================
.PHONY: integrate.wasm
integrate.wasm:
@$(MAKE) integration.wasm
# ==============================================================================
## integrate.runtime: Run integration test with runtime.
# ==============================================================================
.PHONY: integrate.runtime
integrate.runtime:
@$(MAKE) integration.runtime
# ==============================================================================
## format: Format layotto go codes style with gofmt and goimports.
# ==============================================================================
.PHONY: format
format: go.format
# ==============================================================================
## clean: Remove all files that are created by building.
# ==============================================================================
.PHONY: clean
clean:
@$(MAKE) go.clean
# ==============================================================================
## proto.doc: Generate documentation according to the proto files.
# ==============================================================================
.PHONY: proto.doc
proto.doc:
@$(MAKE) proto.gen.doc
# ==============================================================================
## proto.init: Install protoc-gen-go and protoc-gen-go-grpc
# ==============================================================================
.PHONY: proto.init
proto.init:
@$(MAKE) proto.gen.init
# ==============================================================================
## proto.code: Generate pb.go code according to the proto files.
# ==============================================================================
.PHONY: proto.code
proto.code:
@$(MAKE) proto.gen.code
# ==============================================================================
## all: Run format codes, check codes, build Layotto codes for host platform with one command
# ==============================================================================
.PHONY: all
all: clean format check style.quickstart clean
# ==============================================================================
# Usage
# ==============================================================================
define USAGE_OPTIONS
ARGS:
BINS The binaries to build. Default is all of cmd.
This option is available when using: make build/build.multiarch
Example: make build BINS="layotto_multiple_api layotto"
IMAGES Backend images to make. Default is all of cmds.
This option is available when using: make image/image.multiarch/push/push.multiarch
Example: make image.multiarch IMAGES="layotto_multiple_api layotto"
PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64.
This option is available when using: make build.multiarch/image.multiarch/push.multiarch
Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64"
Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64
endef
export USAGE_OPTIONS
# ==============================================================================
# Help
# ==============================================================================
## help: Show this help info.
.PHONY: help
help: Makefile
@echo -e "Layotto commands 👀: \n\nA fast and efficient cloud native application runtime 🚀."
@echo -e "Commands below are used in Development 💻 and GitHub workflow 🌊.\n"
@echo -e "Usage: make <COMMANDS> <ARGS> ...\n\nCOMMANDS:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo "$$USAGE_OPTIONS"