From 137e04acb66c848e0a9d8acddf1ea09682aba95b Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Wed, 1 Apr 2020 09:19:52 -0400 Subject: [PATCH] Added additional build details --- Makefile | 15 +++++++++++++-- cmd/version.go | 6 +++++- common/common.go | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a56095a..ea4d7db 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,17 @@ GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v '*_test.go' GO_TEST_FILES := $(shell find . -name '*_test.go' -type f | rev | cut -d "/" -f2- | rev | sort -u) GO_BUILD_FILES := $(shell find . -name 'main.go') +VERSION := `git describe --tags` +GITCOMMIT := `git rev-parse HEAD` +BUILDDATE := `date +%Y-%m-%d` +BUILDUSER := `whoami` +LDFLAGSSTRING :=-X github.com/zcash/lightwalletd/common.Version=$(VERSION) +LDFLAGSSTRING +=-X github.com/zcash/lightwalletd/common.GitCommit=$(GITCOMMIT) +LDFLAGSSTRING +=-X github.com/zcash/lightwalletd/common.Branch=$(BRANCH) +LDFLAGSSTRING +=-X github.com/zcash/lightwalletd/common.BuildDate=$(BUILDDATE) +LDFLAGSSTRING +=-X github.com/zcash/lightwalletd/common.BuildUser=$(BUILDUSER) +LDFLAGS :=-ldflags "$(LDFLAGSSTRING)" + # There are some files that are generated but are also in source control # (so that the average clone - build doesn't need the required tools) GENERATED_FILES := docs/rtd/index.html walletrpc/compact_formats.pb.go walletrpc/service.pb.go @@ -120,10 +131,10 @@ dep: # Build binary build: - GO111MODULE=on go build -ldflags="-X github.com/zcash/lightwalletd/common.Version=`git describe --tags`" + GO111MODULE=on go build $(LDFLAGS) build_rel: - GO111MODULE=on GOOS=linux go build -ldflags="-X github.com/zcash/lightwalletd/common.Version=`git describe --tags`" + GO111MODULE=on GOOS=linux go build $(LDFLAGS) # Install binaries into Go path install: diff --git a/cmd/version.go b/cmd/version.go index b8161c6..2f3cd7a 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -13,6 +13,10 @@ var versionCmd = &cobra.Command{ Short: "Dispaly lightwalletd version", Long: `Dispaly lightwalletd version.`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("lightwalletd version", common.Version) + fmt.Println("lightwalletd version: ", common.Version) + fmt.Println("from commit: ", common.GitCommit) + fmt.Println("on: ", common.BuildDate) + fmt.Println("by: ", common.BuildUser) + }, } diff --git a/common/common.go b/common/common.go index 6eca701..c6e7d4b 100644 --- a/common/common.go +++ b/common/common.go @@ -18,6 +18,9 @@ import ( // 'make build' will overwrite this string with the output of git-describe (tag) var Version = "v0.0.0.0-dev" +var GitCommit = "" +var BuildDate = "" +var BuildUser = "" type Options struct { BindAddr string `json:"bind_address,omitempty"`