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 4.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 CLEAN_HELP_INFO
  104. # Clean up the output of make.
  105. #
  106. # Example:
  107. # make clean
  108. # make clean HELP=y
  109. #
  110. endef
  111. .PHONY: clean
  112. ifeq ($(HELP),y)
  113. clean:
  114. @echo "$$CLEAN_HELP_INFO"
  115. else
  116. clean:
  117. hack/make-rules/clean.sh
  118. endif
  119. .PHONY: images gmimage lcimage kbimage
  120. images: gmimage lcimage kbimage
  121. gmimage lcimage kbimage:
  122. docker build --build-arg GO_LDFLAGS=${GO_LDFLAGS} -t ${IMAGE_REPO}/sedna-${@:image=}:${IMAGE_TAG} -f build/${@:image=}/Dockerfile .
  123. .PHONY: push push-examples push-all push-multi-platform-images
  124. push-all: push-multi-platform-images push-examples
  125. # push target pushes sedna-built images
  126. push: images
  127. for target in $(COMPONENTS); do \
  128. docker push ${IMAGE_REPO}/sedna-$$target:${IMAGE_TAG}
  129. done
  130. bash scripts/storage-initializer/push_image.sh
  131. push-examples:
  132. bash examples/push_image.sh
  133. # push multi-platform images
  134. push-multi-platform-images:
  135. bash hack/make-rules/push.sh
  136. .PHONY: e2e
  137. e2e:
  138. hack/run-e2e.sh
  139. # Generate CRDs by kubebuilder
  140. .PHONY: crds controller-gen
  141. crds: controller-gen
  142. $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./pkg/apis/sedna/v1alpha1" output:crd:artifacts:config=build/crds
  143. # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
  144. ifeq (,$(shell go env GOBIN))
  145. GOBIN=$(shell go env GOPATH)/bin
  146. else
  147. GOBIN=$(shell go env GOBIN)
  148. endif
  149. # find or download controller-gen
  150. # download controller-gen if necessary
  151. controller-gen:
  152. ifeq (, $(shell which controller-gen))
  153. @{ \
  154. set -e ;\
  155. CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
  156. cd $$CONTROLLER_GEN_TMP_DIR ;\
  157. go mod init tmp ;\
  158. go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
  159. rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
  160. }
  161. CONTROLLER_GEN=$(GOBIN)/controller-gen
  162. else
  163. CONTROLLER_GEN=$(shell which controller-gen)
  164. endif