-
Notifications
You must be signed in to change notification settings - Fork 167
/
Makefile
209 lines (179 loc) · 4.96 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
# Copyright 2021 The KubeEdge 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.
GOPATH ?= $(shell go env GOPATH)
OUT_DIR ?= _output
OUT_BINPATH := $(OUT_DIR)/bin
OUT_IMAGESPATH := $(OUT_DIR)/images
IMAGE_REPO ?= kubeedge
# the env PLATFORMS defines to generate linux images for amd 64-bit, arm 64-bit and armv7 architectures
# the full list of PLATFORMS is linux/amd64,linux/arm64,linux/arm/v7
PLATFORMS ?= linux/amd64,linux/arm64
COMPONENTS ?= gm lc kb
IMAGE_TAG ?= v0.3.0
GO_LDFLAGS ?= ""
# set allowDangerousTypes for allowing float
CRD_OPTIONS ?= "crd:crdVersions=v1,allowDangerousTypes=true"
# make all builds both gm and lc binaries
BINARIES=gm lc
SHELL=/bin/bash
.EXPORT_ALL_VARIABLES:
define BUILD_HELP_INFO
# Build code with verifying or not.
# target all is the "build" with verify.
# Args:
# WHAT: binary names to build. support: $(BINARIES)
# the build will produce executable files under ./$(OUT_BINPATH)
# If not specified, "everything" will be built.
#
# Example:
# make TARGET
# make TARGET HELP=y
# make TARGET WHAT=gm
# make TARGET WHAT=lc GOLDFLAGS="" GOGCFLAGS="-N -l"
# Note: Specify GOLDFLAGS as an empty string for building unstripped binaries, specify GOGCFLAGS
# to "-N -l" to disable optimizations and inlining, this will be helpful when you want to
# use the debugging tools like delve. When GOLDFLAGS is unspecified, it defaults to "-s -w" which strips
# debug information, see https://golang.org/cmd/link for other flags.
endef
.PHONY: build docker-cross-build all
ifeq ($(HELP),y)
build all:
@echo "$${BUILD_HELP_INFO//TARGET/$@}"
else
# build without verify
# default target
build:
hack/make-rules/build.sh $(WHAT)
# build multi-platform images and results will be saved in tar packages.
docker-cross-build:
bash hack/make-rules/cross-build.sh
all: verify build
endif
define VERIFY_HELP_INFO
# verify golang, vendor, vendor licenses and codegen
#
# Example:
# make verify
endef
.PHONY: verify
ifeq ($(HELP),y)
verify:
@echo "$$VERIFY_HELP_INFO"
else
verify: verify-golang verify-vendor verify-codegen verify-vendor-licenses
endif
.PHONY: verify-golang
verify-golang:
hack/verify-golang.sh
.PHONY: verify-vendor
verify-vendor:
hack/verify-vendor.sh
.PHONY: verify-codegen
verify-codegen:
hack/verify-codegen.sh
.PHONY: verify-vendor-licenses
verify-vendor-licenses:
hack/verify-vendor-licenses.sh
define LINT_HELP_INFO
# run golang lint check.
#
# Example:
# make lint
# make lint HELP=y
endef
.PHONY: lint
ifeq ($(HELP),y)
lint:
@echo "$$LINT_HELP_INFO"
else
lint:
hack/make-rules/lint.sh
endif
define PYLINT_HELP_INFO
# run python lint check.
#
# Example:
# make pylint
# make pylint HELP=y
endef
.PHONY: pylint
ifeq ($(HELP),y)
pylint:
@echo "$$PYLINT_HELP_INFO"
else
pylint:
hack/make-rules/pylint.sh
endif
define CLEAN_HELP_INFO
# Clean up the output of make.
#
# Example:
# make clean
# make clean HELP=y
#
endef
.PHONY: clean
ifeq ($(HELP),y)
clean:
@echo "$$CLEAN_HELP_INFO"
else
clean:
hack/make-rules/clean.sh
endif
.PHONY: images gmimage lcimage kbimage
images: gmimage lcimage kbimage
gmimage lcimage kbimage:
docker build --build-arg GO_LDFLAGS=${GO_LDFLAGS} -t ${IMAGE_REPO}/sedna-${@:image=}:${IMAGE_TAG} -f build/${@:image=}/Dockerfile .
.PHONY: push push-examples push-all push-multi-platform-images
push-all: push-multi-platform-images push-examples
# push target pushes sedna-built images
push: images
for target in $(COMPONENTS); do \
docker push ${IMAGE_REPO}/sedna-$$target:${IMAGE_TAG}
done
bash scripts/storage-initializer/push_image.sh
push-examples:
bash examples/push_image.sh
# push multi-platform images
push-multi-platform-images:
bash hack/make-rules/push.sh
.PHONY: e2e
e2e:
hack/run-e2e.sh
# Generate CRDs by kubebuilder
.PHONY: crds controller-gen
crds: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./pkg/apis/sedna/v1alpha1" output:crd:artifacts:config=build/crds
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif