make: allow using a development version of Go, with a warning (#2260)

This commit is contained in:
mmetc 2023-06-05 13:02:37 +02:00 committed by GitHub
parent e3cb4ab2c4
commit 18764eff0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,8 @@
include mk/platform.mk
BUILD_REQUIRE_GO_MAJOR ?= 1
BUILD_REQUIRE_GO_MINOR ?= 20
BUILD_CODENAME ?= alphaga
CROWDSEC_FOLDER = ./cmd/crowdsec

View file

@ -1,7 +1,4 @@
BUILD_REQUIRE_GO_MAJOR ?= 1
BUILD_REQUIRE_GO_MINOR ?= 20
BUILD_GOVERSION = $(subst go,,$(shell go env GOVERSION))
go_major_minor = $(subst ., ,$(BUILD_GOVERSION))
@ -10,8 +7,19 @@ GO_MINOR_VERSION = $(word 2, $(go_major_minor))
GO_VERSION_VALIDATION_ERR_MSG = Golang version ($(BUILD_GOVERSION)) is not supported, please use at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR)
.PHONY: goversion
goversion:
goversion: $(if $(findstring devel,$(shell go env GOVERSION)),goversion_devel,goversion_check)
.PHONY: goversion_devel
goversion_devel:
$(warning WARNING: You are using a development version of Golang ($(BUILD_GOVERSION)) which is not supported. For production environments, use a stable version (at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR)))
$(info )
.PHONY: goversion_check
goversion_check:
ifneq ($(OS), Windows_NT)
@if [ $(GO_MAJOR_VERSION) -gt $(BUILD_REQUIRE_GO_MAJOR) ]; then \
exit 0; \