Skip to content

Commit

Permalink
enrich version command's output
Browse files Browse the repository at this point in the history
Closes: #1894
  • Loading branch information
Alessio Treglia committed Jan 22, 2019
1 parent cffa39c commit 9e3b2b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
VERSION := $(subst v,,$(shell git describe --tags --long))
BUILD_TAGS = netgo
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION}"
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION} -X github.com/cosmos/cosmos-sdk/version.VendorDirHash=$(shell cat vendor-deps)"
LEDGER_ENABLED ?= true
GOTOOLS = \
github.com/golang/dep/cmd/dep \
github.com/alecthomas/gometalinter \
github.com/rakyll/statik
GOBIN ?= $(GOPATH)/bin
all: devtools get_vendor_deps install install_examples install_cosmos-sdk-cli test_lint test
all: devtools vendor-deps install install_examples install_cosmos-sdk-cli test_lint test

# The below include contains the tools target.
include scripts/Makefile

########################################
### CI

ci: devtools get_vendor_deps install test_cover test_lint test
ci: devtools vendor-deps install test_cover test_lint test

########################################
### Build/Install
Expand Down Expand Up @@ -131,10 +131,11 @@ devtools-stamp: tools
go get github.com/tendermint/lint/golint
touch $@

get_vendor_deps: tools
vendor-deps: tools
@echo "--> Generating vendor directory via dep ensure"
@rm -rf .vendor-new
@dep ensure -v -vendor-only
tar -c vendor/ | sha1sum | cut -d' ' -f1 > $@

update_vendor_deps: tools
@echo "--> Running dep ensure"
Expand All @@ -147,7 +148,7 @@ draw_deps: tools
@goviz -i github.com/cosmos/cosmos-sdk/cmd/gaia/cmd/gaiad -d 2 | dot -Tpng -o dependency-graph.png

clean:
rm -f devtools-stamp
rm -f devtools-stamp vendor-deps

########################################
### Documentation
Expand Down Expand Up @@ -268,7 +269,7 @@ localnet-stop:
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build build_cosmos-sdk-cli build_examples install install_examples install_cosmos-sdk-cli install_debug dist \
check_tools check_dev_tools get_vendor_deps draw_deps test test_cli test_unit \
check_tools check_dev_tools draw_deps test test_cli test_unit \
test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update \
build-linux build-docker-gaiadnode localnet-start localnet-stop \
format check-ledger test_sim_gaia_nondeterminism test_sim_modules test_sim_gaia_fast \
Expand Down
5 changes: 4 additions & 1 deletion version/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package version

import (
"fmt"
"runtime"

"github.com/spf13/cobra"
)
Expand All @@ -22,5 +23,7 @@ func GetVersion() string {

// CMD
func printVersion(cmd *cobra.Command, args []string) {
fmt.Println(GetVersion())
fmt.Println("cosmos-sdk", GetVersion())
fmt.Println("Built with Go", runtime.Version())
fmt.Println("vendor/ directory's hash:", VendorDirHash)
}
3 changes: 3 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ package version

// GitCommit set by build flags
var Version = ""

// VendorDirHash is set by build flags
var VendorDirHash = ""

0 comments on commit 9e3b2b6

Please sign in to comment.