mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +00:00
build: check golang version meets min req.
Check that the system golang version is new enough to build with according to the data from the `versions.yaml` file. Update the verions in the versions.yaml accordingly, and add a note describing what the 'newest-version' item represents. Note, we only do a minimum requirement check, and are not checking against the 'newest-version' info from the yaml. Fixes: #148 Inspired-by: Wei Zhang <zhangwei555@huawei.com> Idea-by: James O. D. Hunt <james.o.hunt@intel.com> Signed-off-by: Graham Whaley <graham.whaley@intel.com>
This commit is contained in:
parent
eaa5c7a442
commit
95f4fdb603
2
Makefile
2
Makefile
@ -15,6 +15,8 @@ done)
|
||||
GOARCH=$(shell go env GOARCH)
|
||||
HOST_ARCH=$(shell arch)
|
||||
|
||||
include golang.mk
|
||||
|
||||
ifeq ($(ARCH),)
|
||||
ARCH = $(GOARCH)
|
||||
endif
|
||||
|
46
golang.mk
Normal file
46
golang.mk
Normal file
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Check that the system golang version is within the required version range
|
||||
# for this project.
|
||||
|
||||
golang_version_min=$(shell yq r versions.yaml languages.golang.version)
|
||||
|
||||
ifeq (,$(golang_version_min))
|
||||
$(error "ERROR: cannot determine minimum golang version")
|
||||
endif
|
||||
|
||||
golang_version_min_fields=$(subst ., ,$(golang_version_min))
|
||||
|
||||
golang_version_min_major=$(word 1,$(golang_version_min_fields))
|
||||
golang_version_min_minor=$(word 2,$(golang_version_min_fields))
|
||||
|
||||
# for error messages
|
||||
golang_version_needed=$(golang_version_min_major).$(golang_version_min_minor)
|
||||
|
||||
golang_version_raw=$(shell go version 2>/dev/null)
|
||||
|
||||
ifeq (,$(golang_version_raw))
|
||||
$(error "ERROR: cannot determine golang version")
|
||||
endif
|
||||
|
||||
# determine actual version of golang
|
||||
golang_version=$(subst go,,$(word 3,$(golang_version_raw)))
|
||||
|
||||
golang_version_fields=$(subst ., ,$(golang_version))
|
||||
|
||||
golang_version_major=$(word 1,$(golang_version_fields))
|
||||
golang_version_minor=$(word 2,$(golang_version_fields))
|
||||
|
||||
golang_major_ok=$(shell test $(golang_version_major) -ge $(golang_version_min_major) && echo ok)
|
||||
golang_minor_ok=$(shell test $(golang_version_major) -eq $(golang_version_min_major) -a $(golang_version_minor) -ge $(golang_version_min_minor) && echo ok)
|
||||
|
||||
ifeq (,$(golang_major_ok))
|
||||
$(error "ERROR: golang major version too old: got $(golang_version), need atleast $(golang_version_needed)")
|
||||
endif
|
||||
|
||||
ifeq (,$(golang_minor_ok))
|
||||
$(error "ERROR: golang minor version too old: got $(golang_version), need atleast $(golang_version_needed)")
|
||||
endif
|
@ -189,7 +189,10 @@ languages:
|
||||
issue: "https://github.com/golang/go/issues/20676"
|
||||
version: "1.10.4"
|
||||
meta:
|
||||
newest-version: "1.11"
|
||||
description: |
|
||||
'newest-version' is the latest version known to work when
|
||||
building Kata
|
||||
newest-version: "1.11.1"
|
||||
|
||||
specs:
|
||||
description: "Details of important specifications"
|
||||
|
Loading…
Reference in New Issue
Block a user