diff --git a/Makefile b/Makefile index a8a4b66e8d..0f4d4afdd9 100644 --- a/Makefile +++ b/Makefile @@ -14,20 +14,18 @@ GORUN = env GO111MODULE=on go run GOPATH = $(shell go env GOPATH) GIT_COMMIT ?= $(shell git rev-list -1 HEAD) -GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) -GIT_TAG ?= $(shell git describe --tags `git rev-list --tags="v*" --max-count=1`) PACKAGE = github.com/ethereum/go-ethereum GO_FLAGS += -buildvcs=false -GO_FLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} -X ${PACKAGE}/params.GitBranch=${GIT_BRANCH} -X ${PACKAGE}/params.GitTag=${GIT_TAG}" +GO_LDFLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} " TESTALL = $$(go list ./... | grep -v go-ethereum/cmd/) TESTE2E = ./tests/... -GOTEST = GODEBUG=cgocheck=0 go test $(GO_FLAGS) -p 1 +GOTEST = GODEBUG=cgocheck=0 go test $(GO_FLAGS) $(GO_LDFLAGS) -p 1 bor: mkdir -p $(GOPATH)/bin/ - go build -o $(GOBIN)/bor ./cmd/cli/main.go + go build -o $(GOBIN)/bor $(GO_LDFLAGS) ./cmd/cli/main.go cp $(GOBIN)/bor $(GOPATH)/bin/ @echo "Done building." diff --git a/internal/cli/version.go b/internal/cli/version.go index cd155f43a7..949599904e 100644 --- a/internal/cli/version.go +++ b/internal/cli/version.go @@ -46,7 +46,7 @@ func (c *VersionCommand) Synopsis() string { // Run implements the cli.Command interface func (c *VersionCommand) Run(args []string) int { - c.UI.Output(params.VersionWithMeta) + c.UI.Output(params.VersionWithMetaCommitDetails) return 0 } diff --git a/params/version.go b/params/version.go index 199e49095f..0e4afc7bcb 100644 --- a/params/version.go +++ b/params/version.go @@ -27,6 +27,10 @@ const ( VersionMeta = "stable" // Version metadata to append to the version string ) +var ( + GitCommit = "" +) + // Version holds the textual version string. var Version = func() string { return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch) @@ -41,6 +45,16 @@ var VersionWithMeta = func() string { return v }() +// VersionWithCommitDetails holds the textual version string including the metadata and Git Details. +var VersionWithMetaCommitDetails = func() string { + v := Version + if VersionMeta != "" { + v += "-" + VersionMeta + } + v_git := fmt.Sprintf("Version : %s\nGitCommit : %s\n", v, GitCommit) + return v_git +}() + // ArchiveVersion holds the textual version string used for Geth archives. // e.g. "1.8.11-dea1ce05" for stable releases, or //