You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 5.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. # Copyright 2021 The KubeEdge Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. GOPATH ?= $(shell go env GOPATH)
  15. OUT_DIR ?= _output
  16. OUT_BINPATH := $(OUT_DIR)/bin
  17. OUT_IMAGESPATH := $(OUT_DIR)/images
  18. IMAGE_REPO ?= kubeedge
  19. # the env PLATFORMS defines to generate linux images for amd 64-bit, arm 64-bit and armv7 architectures
  20. # the full list of PLATFORMS is linux/amd64,linux/arm64,linux/arm/v7
  21. PLATFORMS ?= linux/amd64,linux/arm64
  22. COMPONENTS ?= gm lc kb
  23. IMAGE_TAG ?= v0.3.0
  24. GO_LDFLAGS ?= ""
  25. # set allowDangerousTypes for allowing float
  26. CRD_OPTIONS ?= "crd:crdVersions=v1,allowDangerousTypes=true"
  27. # make all builds both gm and lc binaries
  28. BINARIES=gm lc
  29. SHELL=/bin/bash
  30. .EXPORT_ALL_VARIABLES:
  31. define BUILD_HELP_INFO
  32. # Build code with verifying or not.
  33. # target all is the "build" with verify.
  34. # Args:
  35. # WHAT: binary names to build. support: $(BINARIES)
  36. # the build will produce executable files under ./$(OUT_BINPATH)
  37. # If not specified, "everything" will be built.
  38. #
  39. # Example:
  40. # make TARGET
  41. # make TARGET HELP=y
  42. # make TARGET WHAT=gm
  43. # make TARGET WHAT=lc GOLDFLAGS="" GOGCFLAGS="-N -l"
  44. # Note: Specify GOLDFLAGS as an empty string for building unstripped binaries, specify GOGCFLAGS
  45. # to "-N -l" to disable optimizations and inlining, this will be helpful when you want to
  46. # use the debugging tools like delve. When GOLDFLAGS is unspecified, it defaults to "-s -w" which strips
  47. # debug information, see https://golang.org/cmd/link for other flags.
  48. endef
  49. .PHONY: build docker-cross-build all
  50. ifeq ($(HELP),y)
  51. build all:
  52. @echo "$${BUILD_HELP_INFO//TARGET/$@}"
  53. else
  54. # build without verify
  55. # default target
  56. build:
  57. hack/make-rules/build.sh $(WHAT)
  58. # build multi-platform images and results will be saved in tar packages.
  59. docker-cross-build:
  60. bash hack/make-rules/cross-build.sh
  61. all: verify build
  62. endif
  63. define VERIFY_HELP_INFO
  64. # verify golang, vendor, vendor licenses and codegen
  65. #
  66. # Example:
  67. # make verify
  68. endef
  69. .PHONY: verify
  70. ifeq ($(HELP),y)
  71. verify:
  72. @echo "$$VERIFY_HELP_INFO"
  73. else
  74. verify: verify-golang verify-vendor verify-codegen verify-vendor-licenses
  75. endif
  76. .PHONY: verify-golang
  77. verify-golang:
  78. hack/verify-golang.sh
  79. .PHONY: verify-vendor
  80. verify-vendor:
  81. hack/verify-vendor.sh
  82. .PHONY: verify-codegen
  83. verify-codegen:
  84. hack/verify-codegen.sh
  85. .PHONY: verify-vendor-licenses
  86. verify-vendor-licenses:
  87. hack/verify-vendor-licenses.sh
  88. define LINT_HELP_INFO
  89. # run golang lint check.
  90. #
  91. # Example:
  92. # make lint
  93. # make lint HELP=y
  94. endef
  95. .PHONY: lint
  96. ifeq ($(HELP),y)
  97. lint:
  98. @echo "$$LINT_HELP_INFO"
  99. else
  100. lint:
  101. hack/make-rules/lint.sh
  102. endif
  103. define PYLINT_HELP_INFO
  104. # run python lint check.
  105. #
  106. # Example:
  107. # make pylint
  108. # make pylint HELP=y
  109. endef
  110. .PHONY: pylint
  111. ifeq ($(HELP),y)
  112. pylint:
  113. @echo "$$PYLINT_HELP_INFO"
  114. else
  115. pylint:
  116. hack/make-rules/pylint.sh
  117. endif
  118. define CLEAN_HELP_INFO
  119. # Clean up the output of make.
  120. #
  121. # Example:
  122. # make clean
  123. # make clean HELP=y
  124. #
  125. endef
  126. .PHONY: clean
  127. ifeq ($(HELP),y)
  128. clean:
  129. @echo "$$CLEAN_HELP_INFO"
  130. else
  131. clean:
  132. hack/make-rules/clean.sh
  133. endif
  134. .PHONY: images gmimage lcimage kbimage
  135. images: gmimage lcimage kbimage
  136. gmimage lcimage kbimage:
  137. docker build --build-arg GO_LDFLAGS=${GO_LDFLAGS} -t ${IMAGE_REPO}/sedna-${@:image=}:${IMAGE_TAG} -f build/${@:image=}/Dockerfile .
  138. .PHONY: push push-examples push-all push-multi-platform-images
  139. push-all: push-multi-platform-images push-examples
  140. # push target pushes sedna-built images
  141. push: images
  142. for target in $(COMPONENTS); do \
  143. docker push ${IMAGE_REPO}/sedna-$$target:${IMAGE_TAG}
  144. done
  145. bash scripts/storage-initializer/push_image.sh
  146. push-examples:
  147. bash examples/push_image.sh
  148. # push multi-platform images
  149. push-multi-platform-images:
  150. bash hack/make-rules/push.sh
  151. .PHONY: e2e
  152. e2e:
  153. hack/run-e2e.sh
  154. # Generate CRDs by kubebuilder
  155. .PHONY: crds controller-gen
  156. crds: controller-gen
  157. $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./pkg/apis/sedna/v1alpha1" output:crd:artifacts:config=build/crds
  158. # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
  159. ifeq (,$(shell go env GOBIN))
  160. GOBIN=$(shell go env GOPATH)/bin
  161. else
  162. GOBIN=$(shell go env GOBIN)
  163. endif
  164. # find or download controller-gen
  165. # download controller-gen if necessary
  166. controller-gen:
  167. ifeq (, $(shell which controller-gen))
  168. @{ \
  169. set -e ;\
  170. CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
  171. cd $$CONTROLLER_GEN_TMP_DIR ;\
  172. go mod init tmp ;\
  173. go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
  174. rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
  175. }
  176. CONTROLLER_GEN=$(GOBIN)/controller-gen
  177. else
  178. CONTROLLER_GEN=$(shell which controller-gen)
  179. endif