diff --git a/Makefile b/Makefile index 4f419b9638..fa6daa757c 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ done) GOARCH=$(shell go env GOARCH) HOST_ARCH=$(shell arch) +include golang.mk + ifeq ($(ARCH),) ARCH = $(GOARCH) endif diff --git a/golang.mk b/golang.mk new file mode 100644 index 0000000000..95259d1920 --- /dev/null +++ b/golang.mk @@ -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 diff --git a/versions.yaml b/versions.yaml index cc26c01262..7df7144660 100644 --- a/versions.yaml +++ b/versions.yaml @@ -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"