From 1428cd6a5cf8633db506a22e3c8bd81c671a4781 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Wed, 5 Aug 2020 02:21:14 +0200 Subject: [PATCH] fix app version (#427) --- Makefile | 91 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 129cbc00..ae288230 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +#!/usr/bin/make -f + +VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') +COMMIT := $(shell git log -1 --format='%H') PACKAGES=$(shell go list ./... | grep -Ev 'vendor|importer|rpc/tester') -COMMIT_HASH := $(shell git rev-parse --short HEAD) -BUILD_FLAGS = -tags netgo -ldflags "-X github.com/cosmos/ethermint/version.GitCommit=${COMMIT_HASH}" DOCKER_TAG = unstable DOCKER_IMAGE = cosmos/ethermint ETHERMINT_DAEMON_BINARY = emintd @@ -24,6 +26,75 @@ BINDIR ?= $(GOPATH)/bin BUILDDIR ?= $(CURDIR)/build SIMAPP = github.com/cosmos/ethermint/app RUNSIM = $(BINDIR)/runsim +LEDGER_ENABLED ?= true + +ifeq ($(DETECTED_OS),) + ifeq ($(OS),Windows_NT) + DETECTED_OS := windows + else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S),Darwin) + DETECTED_OS := mac + else + DETECTED_OS := linux + endif + endif +endif +export GO111MODULE = on + +# process build tags + +build_tags = netgo +ifeq ($(LEDGER_ENABLED),true) + ifeq ($(OS),Windows_NT) + GCCEXE = $(shell where gcc.exe 2> NUL) + ifeq ($(GCCEXE),) + $(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) + else + build_tags += ledger + endif + else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S),OpenBSD) + $(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) + else + GCC = $(shell command -v gcc 2> /dev/null) + ifeq ($(GCC),) + $(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) + else + build_tags += ledger + endif + endif + endif +endif + +ifeq ($(WITH_CLEVELDB),yes) + build_tags += gcc +endif +build_tags += $(BUILD_TAGS) +build_tags := $(strip $(build_tags)) + +whitespace := +whitespace += $(whitespace) +comma := , +build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) + +# process linker flags + +ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=ethermint \ + -X github.com/cosmos/cosmos-sdk/version.ServerName=$(ETHERMINT_DAEMON_BINARY) \ + -X github.com/cosmos/cosmos-sdk/version.ClientName=$(ETHERMINT_CLI_BINARY) \ + -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ + -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ + -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" + +ifeq ($(WITH_CLEVELDB),yes) + ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb +endif +ldflags += $(LDFLAGS) +ldflags := $(strip $(ldflags)) + +BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' all: tools verify install @@ -32,6 +103,13 @@ all: tools verify install ############################################################################### build: go.sum +ifeq ($(OS), Windows_NT) + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/$(ETHERMINT_DAEMON_BINARY).exe ./cmd/$(ETHERMINT_DAEMON_BINARY) + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/$(ETHERMINT_CLI_BINARY).exe ./cmd/$(ETHERMINT_CLI_BINARY) +else + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/$(ETHERMINT_DAEMON_BINARY) ./cmd/$(ETHERMINT_DAEMON_BINARY) + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/$(ETHERMINT_CLI_BINARY) ./cmd/$(ETHERMINT_CLI_BINARY) +endif go build -mod=readonly ./... build-ethermint: go.sum @@ -51,15 +129,6 @@ install: clean: @rm -rf ./build ./vendor -update-tools: - @echo "--> Updating vendor dependencies" - ${GO_MOD} go get -u -v $(GOLINT) $(UNCONVERT) $(INEFFASSIGN) $(MISSPELL) $(ERRCHECK) $(UNPARAM) - ${GO_MOD} go get -u -v $(GOCILINT) - -verify: - @echo "--> Verifying dependencies have not been modified" - ${GO_MOD} go mod verify - docker: docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} . docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest