github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/Makefile (about) 1 Dirs=$(shell ls) 2 3 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) 4 ifneq (,$(shell go env GOBIN)) 5 GOBIN=$(shell go env GOPATH)/bin 6 else 7 GOBIN=$(shell go env GOBIN) 8 endif 9 10 help: ## this help 11 @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) 12 13 fmt: ## Run go fmt against code. 14 go fmt ./... 15 16 vet: ## Run go vet against code. 17 go vet ./... 18 19 lint: ## Run go lint against code. 20 golangci-lint run -v ./... 21 22 style: fmt vet lint ## code style: fmt,vet,lint 23 24 build: clean ## build binaries by default 25 @echo "build sealer and sealutil bin" 26 hack/build.sh 27 28 linux: clean ## build binaries for linux 29 @echo "build sealer and sealutil bin for linux" 30 GOOS=linux GOARCH=amd64 hack/build.sh $(GitTag) 31 32 test-sealer: 33 @echo "run e2e test for sealer bin" 34 hack/test-sealer.sh 35 36 clean: ## clean 37 @rm -rf _output 38 39 install-addlicense: ## check license if not exist install addlicense tools 40 ifeq (, $(shell which addlicense)) 41 @{ \ 42 set -e ;\ 43 LICENSE_TMP_DIR=$$(mktemp -d) ;\ 44 cd $$LICENSE_TMP_DIR ;\ 45 go mod init tmp ;\ 46 go get -v github.com/google/addlicense ;\ 47 rm -rf $$LICENSE_TMP_DIR ;\ 48 } 49 ADDLICENSE_BIN=$(GOBIN)/addlicense 50 else 51 ADDLICENSE_BIN=$(shell which addlicense) 52 endif 53 54 filelicense: SHELL:=/bin/bash 55 filelicense: ## add license 56 for file in ${Dirs} ; do \ 57 if [[ $$file != '_output' && $$file != 'docs' && $$file != 'vendor' && $$file != 'logger' && $$file != 'applications' ]]; then \ 58 $(ADDLICENSE_BIN) -y $(shell date +"%Y") -c "Alibaba Group Holding Ltd." -f hack/LICENSE_TEMPLATE ./$$file ; \ 59 fi \ 60 done 61 62 63 install-gosec: ## check license if not exist install addlicense tools 64 ifeq (, $(shell which gosec)) 65 @{ \ 66 set -e ;\ 67 curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(GOBIN) v2.2.0 ;\ 68 } 69 GOSEC_BIN=$(GOBIN)/gosec 70 else 71 GOSEC_BIN=$(shell which gosec) 72 endif 73 74 gosec: install-gosec 75 $(GOSEC_BIN) ./... 76 77 78 install-deepcopy-gen: 79 ifeq (, $(shell which deepcopy-gen)) 80 @{ \ 81 set -e ;\ 82 LICENSE_TMP_DIR=$$(mktemp -d) ;\ 83 cd $$LICENSE_TMP_DIR ;\ 84 go mod init tmp ;\ 85 go get -v k8s.io/code-generator/cmd/deepcopy-gen ;\ 86 rm -rf $$LICENSE_TMP_DIR ;\ 87 } 88 DEEPCOPY_BIN=$(GOBIN)/deepcopy-gen 89 else 90 DEEPCOPY_BIN=$(shell which deepcopy-gen) 91 endif 92 93 HEAD_FILE := hack/boilerplate.go.txt 94 INPUT_DIR := github.com/alibaba/sealer/types/api 95 deepcopy:install-deepcopy-gen 96 $(DEEPCOPY_BIN) \ 97 --input-dirs="$(INPUT_DIR)/v1" \ 98 -O zz_generated.deepcopy \ 99 --go-header-file "$(HEAD_FILE)" \ 100 --output-base "${GOPATH}/src" 101 $(DEEPCOPY_BIN) \ 102 --input-dirs="$(INPUT_DIR)/v2" \ 103 -O zz_generated.deepcopy \ 104 --go-header-file "$(HEAD_FILE)" \ 105 --output-base "${GOPATH}/src"