This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Graham Whaley
committed
Oct 30, 2018
1 parent
1fe408e
commit b318759
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters