diff options
author | Rasmus Stougaard <rasmus.stougaard@gmail.com> | 2014-11-24 22:45:48 +0700 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2014-11-24 17:25:51 -0500 |
commit | c5ae2a2d1d0ceffbdb88a90f00519dfaec3806d6 (patch) | |
tree | e9faddaa11b73539ffd2235b104eebc178346a26 /Makefile | |
parent | 9b850c4adb2602a453ec19162e48e080f89775be (diff) |
Added makefile that builds with git information
I have put the extra linker flags in a makefile to avoid having to remember the long command to get the commitHash in the version command.
See comment by tatsushid here:
https://github.com/spf13/hugo/issues/540
NB: only tested on Mac OS x 10.10.1 since that is what I have access to
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..b8842fc0d --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ + +# Adds build information from git repo +# +# as suggested by tatsushid in +# https://github.com/spf13/hugo/issues/540 + +COMMIT_HASH=`git rev-parse --short HEAD 2>/dev/null` +BUILD_DATE=`date +%FT%T%z` +LDFLAGS=-ldflags "-X github.com/spf13/hugo/commands.commitHash ${COMMIT_HASH} -X github.com/spf13/hugo/commands.buildDate ${BUILD_DATE}" + +all: gitinfo + +help: + echo ${COMMIT_HASH} + echo ${BUILD_DATE} + +gitinfo: + go build ${LDFLAGS} -o hugo main.go + +no-git-info: + go build -o hugo main.go + |