Skip to content

Commit

Permalink
make+build: compile SHA1 commit hash into binary
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed Apr 10, 2020
1 parent b68764f commit 75a1a1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ ANDROID_BUILD_DIR := $(MOBILE_BUILD_DIR)/android
ANDROID_BUILD := $(ANDROID_BUILD_DIR)/Lndmobile.aar

COMMIT := $(shell git describe --abbrev=40 --dirty)
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
COMMIT_HASH := $(shell git rev-parse HEAD)
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT) \
-X $(PKG)/build.CommitHash=$(COMMIT_HASH)"

BTCD_COMMIT := $(shell cat go.mod | \
grep $(BTCD_PKG) | \
Expand Down
14 changes: 11 additions & 3 deletions build/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ import (
"strings"
)

// Commit stores the current commit hash of this build, this should be set using
// the -ldflags during compilation.
var Commit string
var (
// Commit stores the current commit of this build, which includes the
// most recent tag, the number of commits since that tag (if non-zero),
// the commit hash, and a dirty marker. This should be set using the
// -ldflags during compilation.
Commit string

// CommitHash stores the current commit hash of this build, this should
// be set using the -ldflags during compilation.
CommitHash string
)

// semanticAlphabet is the set of characters that are permitted for use in an
// AppPreRelease.
Expand Down

0 comments on commit 75a1a1f

Please sign in to comment.