Add build date to LDFLAGS

This commit is contained in:
Ryan Cavicchioni 2021-03-02 20:41:18 -06:00
parent de0bc2e133
commit 38ab315a9b
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
3 changed files with 11 additions and 2 deletions

View File

@ -1,14 +1,19 @@
LUME_VERSION ?= $(shell git describe --tags --always)
LDFLAGS := ${LDFLAGS} -X git.kill0.net/chill9/lume/cmd.Version=${LUME_VERSION}
ifeq ($(OS), Windows_NT)
EXE=lume.exe
RM=del /f /q
BUILD_DATE=$(shell powershell Get-Date -Format "yyyy-MM-ddThh:mm:sszzz")
else
EXE=lume
EXE=rm -f
BUILD_DATE=$(shell date --iso-8601=seconds)
endif
LUME_VERSION ?= $(shell git describe --tags --always)
LDFLAGS := ${LDFLAGS} \
-X git.kill0.net/chill9/lume/cmd.Version=${LUME_VERSION} \
-X git.kill0.net/chill9/lume/cmd.BuildDate=${BUILD_DATE}
.PHONY: build
build:
go build -o ${EXE} -ldflags="${LDFLAGS}" ./cmd/lume

View File

@ -30,6 +30,7 @@ func init() {
}
var Version string = "0.1.0-pre"
var BuildDate string
const lumercFile string = ".lumerc"

View File

@ -19,5 +19,8 @@ func VersionCmd(args CmdArgs) (int, error) {
fmt.Printf("lume %s\n", Version)
fmt.Printf(" os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
fmt.Printf(" go version: %s\n", runtime.Version())
if BuildDate != "" {
fmt.Printf(" build date: %s\n", BuildDate)
}
return ExitSuccess, nil
}