Added additional build details

This commit is contained in:
Ben Wilson 2020-04-01 09:19:52 -04:00 committed by Larry Ruane
parent 2fe2d9ac62
commit 137e04acb6
3 changed files with 21 additions and 3 deletions

View File

@ -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:

View File

@ -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)
},
}

View File

@ -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"`