From ae3696e82d146eb6856e8662b3ca197c2b396d79 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 4 Sep 2016 19:20:55 +0300 Subject: [PATCH 1/3] Use Python to get date in cross-platform way I was able to build micro with Mozilla's pymake on Windows --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8df045c6..a1f6effa 100644 --- a/Makefile +++ b/Makefile @@ -2,17 +2,18 @@ VERSION = $(shell git describe --tags --abbrev=0) HASH = $(shell git rev-parse --short HEAD) +DATE = $(shell python -c 'import time; print(time.strftime("%B %d, %Y"))') # Builds micro after checking dependencies but without updating the runtime build: deps tcell - go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(shell date -u '+%B %d, %Y')'" -o micro ./cmd/micro + go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" -o micro ./cmd/micro # Builds micro after building the runtime and checking dependencies build-all: runtime build # Builds micro without checking for dependencies build-quick: - go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(shell date -u '+%B %d, %Y')'" -o micro ./cmd/micro + go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" -o micro ./cmd/micro # Same as 'build' but installs to $GOPATH/bin afterward install: build From 4b350d02e0b2318fe74217a38c78a65b2942eb56 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 4 Sep 2016 19:38:50 +0300 Subject: [PATCH 2/3] Let Go choose binary name and extension This creates micro.exe on Windows --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a1f6effa..c89a7aa5 100644 --- a/Makefile +++ b/Makefile @@ -6,14 +6,14 @@ DATE = $(shell python -c 'import time; print(time.strftime("%B %d, %Y"))') # Builds micro after checking dependencies but without updating the runtime build: deps tcell - go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" -o micro ./cmd/micro + go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" ./cmd/micro # Builds micro after building the runtime and checking dependencies build-all: runtime build # Builds micro without checking for dependencies build-quick: - go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" -o micro ./cmd/micro + go build -ldflags "-X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)'" ./cmd/micro # Same as 'build' but installs to $GOPATH/bin afterward install: build From f2478239366f5061b5f15c0df1625cf961d28ffc Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 4 Sep 2016 22:07:07 +0300 Subject: [PATCH 3/3] Get build date on Windows without Python --- Makefile | 2 +- tools/build-date.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tools/build-date.go diff --git a/Makefile b/Makefile index c89a7aa5..2480d529 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION = $(shell git describe --tags --abbrev=0) HASH = $(shell git rev-parse --short HEAD) -DATE = $(shell python -c 'import time; print(time.strftime("%B %d, %Y"))') +DATE = $(shell go run tools/build-date.go) # Builds micro after checking dependencies but without updating the runtime build: deps tcell diff --git a/tools/build-date.go b/tools/build-date.go new file mode 100644 index 00000000..ff994d2a --- /dev/null +++ b/tools/build-date.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + fmt.Println(time.Now().Local().Format("January 02, 2006")) +}