-
Notifications
You must be signed in to change notification settings - Fork 73
/
Makefile
286 lines (261 loc) · 6.77 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
# =====================================================================
# This file was autogenerated. Do not edit it manually!
# save all your custom variables and targets in Makefile.expansion!
# =====================================================================
#
# Old-skool build tools.
#
# Commonly used targets (see each target for more information):
# all: Build code.
# test: Run tests.
# clean: Clean up.
#
# It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
# Default target
.DEFAULT_GOAL := all
# We don't need make's built-in rules.
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
define command_exists
@$(shell command -v $(1) >/dev/null 2>&1)
endef
# user defined Makefile to expands targets
-include Makefile.expansion
MYMAKE := bash $(MAKE_RULES_ROOT)/entrypoint.sh
define ALL_HELP_INFO
# Build code.
# make all == make build
#
# Args:
# WHAT: Directory names to build. If any of these directories has a 'main'
# package, the build will produce executable files under bin/.
# If not specified, "everything" will be built.
# GOFLAGS: Extra flags to pass to 'go' when building.
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
#
# Example:
# make
# make all or make build
# make build WHAT=cmd/server GOFLAGS=-v
# make all GOGCFLAGS="-N -l"
# Note: Use the -N -l options to disable compiler optimizations an inlining.
# Using these build options allows you to subsequently use source
# debugging tools like delve.
endef
.PHONY: all build
ifeq ($(HELP),y)
all build:
@echo "$$ALL_HELP_INFO"
else
all build:
$(MYMAKE) go build $(WHAT)
endif
docker-images:
./hack/make-rules/build-images.sh
local-up: docker-images
bash ./hack/make-rules/local-up.sh godel-demo-default
local-up-labels: docker-images
bash ./hack/make-rules/local-up.sh godel-demo-labels
define GO_BUILD_HELP_INFO
# Build code.
#
# Args:
# GOFLAGS: Extra flags to pass to 'go' when building.
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
#
# Example:
# make $(1)
# make $(1) GOFLAGS=-v
# make $(1) GOGCFLAGS="-N -l"
# Note: Use the -N -l options to disable compiler optimizations an inlining.
# Using these build options allows you to subsequently use source
# debugging tools like delve.
endef
.PHONY: $(GO_BUILD_TARGETS)
ifeq ($(HELP),y)
$(GO_BUILD_TARGETS):
$(call GO_BUILD_HELP_INFO, $@)
else
$(GO_BUILD_TARGETS):
$(MYMAKE) go build $@
endif
define UNITTEST_HELP_INFO
# Run uniitest
#
# Args:
# GOFLAGS: Extra flags to pass to 'go' when building.
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
#
# Example:
# make
# make unittest
# make unittest GOFLAGS="-v -x"
# make unittest GOGCFLAGS="-N -l"
# Note: Use the -N -l options to disable compiler optimizations an inlining.
# Using these build options allows you to subsequently use source
# debugging tools like delve.
endef
.PHONY: unittest
ifeq ($(HELP),y)
unittest:
@echo "$$UNITTEST_HELP_INFO"
else
unittest:
$(MYMAKE) go unittest
endif
define E2E_TEST_INFO
# get e2e bin file.
#
# Example:
# make e2e
#
endef
.PHONY: e2e
ifeq ($(HELP),y)
e2e:
@echo "$$E2E_TEST_INFO"
else
e2e:
go test -c -o ./bin/linux_amd64/e2e.test github.com/kubewharf/godel-scheduler/test/e2e
endif
.PHONY: logcheck
logcheck:
./hack/verify-logcheck.sh
define BUILD_LOCAL_HELP_INFO
# Build code on local.
#
# Args:
# WHAT: Directory names to build. If any of these directories has a 'main'
# package, the build will produce executable files under bin/.
# If not specified, "everything" will be built.
# GOFLAGS: Extra flags to pass to 'go' when building.
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
#
# Example:
# make
# make build-local
# make build-local WHAT=cmd/server GOFLAGS=-v
# make build-local GOGCFLAGS="-N -l"
# Note: Use the -N -l options to disable compiler optimizations an inlining.
# Using these build options allows you to subsequently use source
# debugging tools like delve.
endef
.PHONY: build-local
ifeq ($(HELP),y)
build-local:
@echo "$$BUILD_LOCAL_HELP_INFO"
else
build-local:
LOCAL_BUILD=true $(MYMAKE) go build $(WHAT)
endif
define BUILD_IN_CONTAINER_HELP_INFO
# Build code in container.
#
# Args:
# WHAT: Directory names to build. If any of these directories has a 'main'
# package, the build will produce executable files under bin/.
# If not specified, "everything" will be built.
# GOFLAGS: Extra flags to pass to 'go' when building.
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
#
# Example:
# make
# make build-in-container
# make build-in-container WHAT=cmd/server GOFLAGS=-v
# make build-in-container GOGCFLAGS="-N -l"
# Note: Use the -N -l options to disable compiler optimizations an inlining.
# Using these build options allows you to subsequently use source
# debugging tools like delve.
endef
.PHONY: build-in-container
ifeq ($(HELP),y)
build-in-container:
@echo "$$BUILD_LINUX_HELP_INFO"
else
build-in-container:
LOCAL_BUILD=false $(MYMAKE) go build $(WHAT)
endif
define CONTAINER_HELP_INFO
# Build container image.
#
# Args:
# WHAT: Directories containing Dockerfile.
#
# Example:
# make container
# make container WHAT=build/server
endef
.PHONY: container
ifeq ($(HELP),y)
container:
@echo "$$CONTAINER_HELP_INFO"
else
container:
$(MYMAKE) container build $(WHAT)
endif
define DOCKER_BUILD_HELP_INFO
# Build container image.
#
# Example:
# make $(1)
endef
.PHONY: $(DOCKER_BUILD_TARGETS)
ifeq ($(HELP),y)
$(DOCKER_BUILD_TARGETS):
$(call DOCKER_BUILD_HELP_INFO, $@)
else
$(DOCKER_BUILD_TARGETS):
$(MYMAKE) container build $@
endif
define PUSH_HELP_INFO
# Push container image.
# You should run make container before push
#
# Args:
# WHAT: Directory names containing Dockerfile.
#
# Example:
# make push
# make push WHAT=build/server
endef
.PHONY: push
ifeq ($(HELP),y)
push:
@echo "$$PUSH_HELP_INFO"
else
push:
$(MYMAKE) container push $(WHAT)
endif
define CLEAN_HELP_INFO
# Remove all container artifacts.
#
# Example:
# make clean
#
endef
.PHONY: clean
ifeq ($(HELP),y)
clean:
@echo "$$CLEAN_HELP_INFO"
else
clean:
$(MYMAKE) clean
endif
.PHONY: manifests
manifests:
@hack/generate-code.sh
.PHONY: debug-makefile
debug-makefile:
$(MYMAKE) debug
.PHONY: fmt
fmt:
gofmt -w ./pkg ./cmd ./test
# format all imports, `goimports` is required.
goimports:
@hack/update-goimports.sh