Skip to content

Commit

Permalink
better variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Mar 7, 2023
1 parent 925cfa6 commit c4040ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mk/goversion.mk
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@

MINIMUM_MAJOR ?= 1
MINIMUM_MINOR ?= 20
BUILD_REQUIRE_GO_MAJOR ?= 1
BUILD_REQUIRE_GO_MINOR ?= 20

BUILD_GOVERSION = $(subst go,,$(shell go env GOVERSION))

go_major_minor = $(subst ., ,$(BUILD_GOVERSION))
GO_MAJOR_VERSION = $(word 1, $(go_major_minor))
GO_MINOR_VERSION = $(word 2, $(go_major_minor))

GO_VERSION_VALIDATION_ERR_MSG = Golang version ($(BUILD_GOVERSION)) is not supported, please use at least $(MINIMUM_MAJOR).$(MINIMUM_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:
ifneq ($(OS), Windows_NT)
@if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_MAJOR) ]; then \
@if [ $(GO_MAJOR_VERSION) -gt $(BUILD_REQUIRE_GO_MAJOR) ]; then \
exit 0; \
elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_MAJOR) ]; then \
elif [ $(GO_MAJOR_VERSION) -lt $(BUILD_REQUIRE_GO_MAJOR) ]; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_MINOR) ] ; then \
elif [ $(GO_MINOR_VERSION) -lt $(BUILD_REQUIRE_GO_MINOR) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
fi
else
# This needs Set-ExecutionPolicy -Scope CurrentUser Unrestricted
@$(CURDIR)/mk/check_go_version.ps1 $(MINIMUM_MAJOR) $(MINIMUM_MINOR)
@$(CURDIR)/mk/check_go_version.ps1 $(BUILD_REQUIRE_GO_MAJOR) $(BUILD_REQUIRE_GO_MINOR)
endif

0 comments on commit c4040ce

Please sign in to comment.