diff options
| author | zhangjie <iamkadisi@163.com> | 2019-10-12 09:40:04 +0800 |
|---|---|---|
| committer | zhangjie <iamkadisi@163.com> | 2019-10-12 13:38:11 +0800 |
| commit | be18148ad33c131bd9682ca663e6a988929ae6b9 (patch) | |
| tree | 74687bb30377dd8166c0ae55ba9ab0f2ff1e3138 | |
| parent | add instructions about gollang version to readme.md (diff) | |
| download | kubeedge-be18148ad33c131bd9682ca663e6a988929ae6b9.tar.gz | |
add golang version check for makefile
Signed-off-by: zhangjie <iamkadisi@163.com>
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | cloud/Makefile | 8 | ||||
| -rw-r--r-- | edge/Makefile | 14 | ||||
| -rw-r--r-- | edgesite/Makefile | 15 | ||||
| -rwxr-xr-x | hack/verify-golang.sh | 43 | ||||
| -rw-r--r-- | keadm/Makefile | 6 |
7 files changed, 74 insertions, 15 deletions
@@ -137,6 +137,7 @@ edgesiteimage: .PHONY: verify verify: + bash hack/verify-golang.sh bash hack/verify-vendor.sh .PHONY: bluetoothdevice @@ -59,8 +59,6 @@ To build KubeEdge from source there is one option: ##### You have a working [Go environment]. -**Note: The recommended golang version is 1.12 ** - ``` mkdir -p $GOPATH/src/github.com/kubeedge cd $GOPATH/src/github.com/kubeedge diff --git a/cloud/Makefile b/cloud/Makefile index 24a488c51..fcb50f2c1 100644 --- a/cloud/Makefile +++ b/cloud/Makefile @@ -7,10 +7,10 @@ GO_LDFLAGS=-ldflags '$(shell ../hack/lib/version.sh)' default: cloudcore admission -cloudcore: +cloudcore: verify go build ${GO_LDFLAGS} cmd/cloudcore/cloudcore.go -admission: +admission: verify go build ${GO_LDFLAGS} cmd/admission/admission.go .PHONY: lint @@ -18,6 +18,10 @@ lint: golangci-lint run --disable-all -E gofmt -E golint --deadline '10m' ./... go vet ./... +.PHONY: verify +verify: + bash ../hack/verify-golang.sh + # Build and run tests. # # Args: diff --git a/edge/Makefile b/edge/Makefile index 0423f06bc..4c423adb0 100644 --- a/edge/Makefile +++ b/edge/Makefile @@ -2,9 +2,13 @@ GO_LDFLAGS=-ldflags '$(shell ../hack/lib/version.sh)' # make edgecore .PHONY: default edgecore -edgecore: +edgecore: verify go build ${GO_LDFLAGS} cmd/edgecore/edgecore.go +.PHONY: verify +verify: + bash ../hack/verify-golang.sh + # unit tests .PHONY: test ifeq ($(WHAT),) @@ -32,7 +36,7 @@ clean: bash -x hack/clean.sh .PHONY: cross_build -cross_build: +cross_build: verify export GOARCH=arm \ export GOOS="linux" \ export GOARM=6 \ @@ -41,7 +45,7 @@ cross_build: go build cmd/edgecore/edgecore.go .PHONY: armv7 -armv7: +armv7: verify export GOARCH=arm \ export GOOS="linux" \ export GOARM=7 \ @@ -50,7 +54,7 @@ armv7: go build cmd/edgecore/edgecore.go .PHONY: armv8 -armv8: +armv8: verify export GOARCH=arm64 \ export GOOS="linux" \ export CGO_ENABLED=1 \ @@ -58,7 +62,7 @@ armv8: go build cmd/edgecore/edgecore.go .PHONY: small_build -small_build: +small_build: verify go build -ldflags="-w -s -extldflags -static" cmd/edgecore/edgecore.go # There are options in upx-ucl like --best, which has best compression, # but also has a drawback of taking too long for big files, we are using -9 since it takes less time diff --git a/edgesite/Makefile b/edgesite/Makefile index 45a140ba5..19e03db84 100644 --- a/edgesite/Makefile +++ b/edgesite/Makefile @@ -1,11 +1,16 @@ GO_LDFLAGS=-ldflags '$(shell ../hack/lib/version.sh)' # make edge_site .PHONY: default edge_site -edge_site: +edge_site: verify go build ${GO_LDFLAGS} cmd/edgesite.go +.PHONY: verify +verify: + bash ../hack/verify-golang.sh + + .PHONY: cross_build -cross_build: +cross_build: verify export GOARCH=arm \ export GOOS="linux" \ export GOARM=6 \ @@ -14,7 +19,7 @@ cross_build: go build cmd/edgesite.go .PHONY: armv7 -armv7: +armv7: verify export GOARCH=arm \ export GOOS="linux" \ export GOARM=7 \ @@ -23,7 +28,7 @@ armv7: go build cmd/edgesite.go .PHONY: armv8 -armv8: +armv8: verify export GOARCH=arm64 \ export GOOS="linux" \ export CGO_ENABLED=1 \ @@ -31,6 +36,6 @@ armv8: go build cmd/edgesite.go .PHONY: small_build -small_build: +small_build: verify go build -ldflags="-w -s -extldflags -static" cmd/edgesite.go upx-ucl --best edge_site diff --git a/hack/verify-golang.sh b/hack/verify-golang.sh new file mode 100755 index 000000000..7a95734c1 --- /dev/null +++ b/hack/verify-golang.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +### +#Copyright 2019 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. +### + +set -o errexit +set -o nounset +set -o pipefail + +# The root of the build/dist directory +KUBEEDGE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" + +echo "go detail version: $(go version)" + +goversion=$(go version |awk -F ' ' '{printf $3}' |sed 's/go//g') + +echo "go version: $goversion" + +X=$(echo $goversion|awk -F '.' '{printf $1}') +Y=$(echo $goversion|awk -F '.' '{printf $2}') + +if [ $X -lt 1 ] ; then + echo "go major version must >= 1, now is $X" + exit 1 +fi + +if [ $Y -lt 12 ] ; then + echo "go minor version must >= 12, now is $Y" + exit 1 +fi diff --git a/keadm/Makefile b/keadm/Makefile index 3449d3b72..b9c9b3a4a 100644 --- a/keadm/Makefile +++ b/keadm/Makefile @@ -2,9 +2,13 @@ GO_LDFLAGS=-ldflags '$(shell ../hack/lib/version.sh)' # make keadm .PHONY: default keadm -keadm: +keadm: verify go build $(GO_LDFLAGS) -o keadm keadm.go +.PHONY: verify +verify: + bash ../hack/verify-golang.sh + lint: golangci-lint run --deadline '10m' --disable-all -E golint ./... go vet ./... |
