Skip to content

Commit

Permalink
[project] Update Makefile to pass in version, commit, built time, bui…
Browse files Browse the repository at this point in the history
…lder information into binary
  • Loading branch information
fxfactorial committed Aug 22, 2019
1 parent 01250dc commit 0d355cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
version=$(shell git rev-list --count HEAD)
commit=$(shell git describe --always --long --dirty)
built_at=$(shell date +%FT%T%z)
built_by=${USER}
version := $(shell git rev-list --count HEAD)
commit := $(shell git describe --always --long --dirty)
built_at := $(shell date +%FT%T%z)
built_by := ${USER}

flags := -gcflags="all=-N -l -c 2"
ldflags := -X main.version=v${version} -X main.commit=${commit}
ldflags += -X main.builtAt=${built_at} -X main.builtBy=${built_by}
cli := hmy_cli

all:
printf '%s %s %s %s\n' $(version) $(commit) $(built_at) $(built_by)
go build $(flags) -o $(cli) client/main.go
go build $(flags) -o $(cli) -ldflags="$(ldflags)" client/main.go

.PHONY:clean

clean:
@rm -f $(cli)
10 changes: 10 additions & 0 deletions client/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package main

import (
"fmt"

"github.com/harmony-one/go-sdk/common"
)

var (
version string
commit string
builtAt string
builtBy string
)

func main() {
fmt.Printf("%s %s %s %s", version, commit, builtAt, builtBy)
common.Speak()
}

0 comments on commit 0d355cf

Please sign in to comment.