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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. IMAGE_REPO ?= kubeedge
  18. IMAGE_TAG ?= v0.1.0
  19. GO_LDFLAGS ?=''
  20. # set allowDangerousTypes for allowing float
  21. CRD_OPTIONS ?= "crd:crdVersions=v1,allowDangerousTypes=true"
  22. # make all builds both gm and lc binaries
  23. BINARIES=gm lc
  24. SHELL=/bin/bash
  25. .EXPORT_ALL_VARIABLES:
  26. define BUILD_HELP_INFO
  27. # Build code with verifying or not.
  28. # target all is the "build" with verify.
  29. # Args:
  30. # WHAT: binary names to build. support: $(BINARIES)
  31. # the build will produce executable files under ./$(OUT_BINPATH)
  32. # If not specified, "everything" will be built.
  33. #
  34. # Example:
  35. # make TARGET
  36. # make TARGET HELP=y
  37. # make TARGET WHAT=gm
  38. # make TARGET WHAT=lc GOLDFLAGS="" GOGCFLAGS="-N -l"
  39. # Note: Specify GOLDFLAGS as an empty string for building unstripped binaries, specify GOGCFLAGS
  40. # to "-N -l" to disable optimizations and inlining, this will be helpful when you want to
  41. # use the debugging tools like delve. When GOLDFLAGS is unspecified, it defaults to "-s -w" which strips
  42. # debug information, see https://golang.org/cmd/link for other flags.
  43. endef
  44. .PHONY: build all
  45. ifeq ($(HELP),y)
  46. build all:
  47. @echo "$${BUILD_HELP_INFO//TARGET/$@}"
  48. else
  49. # build without verify
  50. # default target
  51. build:
  52. hack/make-rules/build.sh $(WHAT)
  53. all: verify build
  54. endif
  55. define VERIFY_HELP_INFO
  56. # verify golang, vendor, vendor licenses and codegen
  57. #
  58. # Example:
  59. # make verify
  60. endef
  61. .PHONY: verify
  62. ifeq ($(HELP),y)
  63. verify:
  64. @echo "$$VERIFY_HELP_INFO"
  65. else
  66. verify: verify-golang verify-vendor verify-codegen verify-vendor-licenses
  67. endif
  68. .PHONY: verify-golang
  69. verify-golang:
  70. hack/verify-golang.sh
  71. .PHONY: verify-vendor
  72. verify-vendor:
  73. hack/verify-vendor.sh
  74. .PHONY: verify-codegen
  75. verify-codegen:
  76. hack/verify-codegen.sh
  77. .PHONY: verify-vendor-licenses
  78. verify-vendor-licenses:
  79. hack/verify-vendor-licenses.sh
  80. define LINT_HELP_INFO
  81. # run golang lint check.
  82. #
  83. # Example:
  84. # make lint
  85. # make lint HELP=y
  86. endef
  87. .PHONY: lint
  88. ifeq ($(HELP),y)
  89. lint:
  90. @echo "$$LINT_HELP_INFO"
  91. else
  92. lint:
  93. hack/make-rules/lint.sh
  94. endif
  95. define CLEAN_HELP_INFO
  96. # Clean up the output of make.
  97. #
  98. # Example:
  99. # make clean
  100. # make clean HELP=y
  101. #
  102. endef
  103. .PHONY: clean
  104. ifeq ($(HELP),y)
  105. clean:
  106. @echo "$$CLEAN_HELP_INFO"
  107. else
  108. clean:
  109. hack/make-rules/clean.sh
  110. endif
  111. .PHONY: images gmimage lcimage
  112. images: gmimage lcimage
  113. gmimage lcimage:
  114. docker build --build-arg GO_LDFLAGS=${GO_LDFLAGS} -t ${IMAGE_REPO}/sedna-${@:image=}:${IMAGE_TAG} -f build/${@:image=}/Dockerfile .
  115. .PHONY: push push-examples push-all
  116. push-all: push push-examples
  117. # push target pushes sedna-built images
  118. push: images
  119. docker push ${IMAGE_REPO}/sedna-gm:${IMAGE_TAG}
  120. docker push ${IMAGE_REPO}/sedna-lc:${IMAGE_TAG}
  121. bash scripts/storage-initializer/push_image.sh
  122. push-examples:
  123. bash examples/push_image.sh
  124. .PHONE: e2e
  125. e2e:
  126. hack/run-e2e.sh
  127. # Generate CRDs by kubebuilder
  128. .PHONY: crds controller-gen
  129. crds: controller-gen
  130. $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./pkg/apis/sedna/v1alpha1" output:crd:artifacts:config=build/crds
  131. # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
  132. ifeq (,$(shell go env GOBIN))
  133. GOBIN=$(shell go env GOPATH)/bin
  134. else
  135. GOBIN=$(shell go env GOBIN)
  136. endif
  137. # find or download controller-gen
  138. # download controller-gen if necessary
  139. controller-gen:
  140. ifeq (, $(shell which controller-gen))
  141. @{ \
  142. set -e ;\
  143. CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
  144. cd $$CONTROLLER_GEN_TMP_DIR ;\
  145. go mod init tmp ;\
  146. go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
  147. rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
  148. }
  149. CONTROLLER_GEN=$(GOBIN)/controller-gen
  150. else
  151. CONTROLLER_GEN=$(shell which controller-gen)
  152. endif