From 86c254bdbd47bcd4e1e898e1b87b6fdc2ab0a80c Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 10 May 2017 13:57:41 -0500 Subject: [PATCH 1/3] Keep ldflags in one place --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 64eca7400..e8ab1e90d 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ VERSION := $(shell git describe --tags 2> /dev/null || echo unknown) IDENTIFIER := $(VERSION)-$(GOOS)-$(GOARCH) CLONE_URL=github.com/pilosa/pilosa BUILD_TIME=`date -u +%FT%T%z` -LDFLAGS=-ldflags "-X github.com/pilosa/pilosa/cmd.Version=$(VERSION) -X github.com/pilosa/pilosa/cmd.BuildTime=$(BUILD_TIME)" +LDFLAGS="-X github.com/pilosa/pilosa/cmd.Version=$(VERSION) -X github.com/pilosa/pilosa/cmd.BuildTime=$(BUILD_TIME)" default: test pilosa @@ -31,14 +31,14 @@ test: vendor go test $(shell cd $(GOPATH)/src/$(CLONE_URL); go list ./... | grep -v vendor) pilosa: vendor - go build $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa + go build -ldflags $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa crossbuild: vendor mkdir -p build/pilosa-$(IDENTIFIER) make pilosa FLAGS="-o build/pilosa-$(IDENTIFIER)/pilosa" install: vendor - go install $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa + go install -ldflags $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa .protoc-gen-gofast: vendor ifndef PROTOC @@ -61,7 +61,5 @@ ifndef STATIK endif docker: - docker build -t "pilosa:$(VERSION)" \ - --build-arg ldflags="-X github.com/pilosa/pilosa/cmd.Version=$(VERSION) \ - -X github.com/pilosa/pilosa/cmd.BuildTime=$(BUILD_TIME)" . + docker build -t "pilosa:$(VERSION)" --build-arg ldflags=$(LDFLAGS) . @echo "Created image: pilosa:$(VERSION)" From 6c11746ac8391e2597ba7db186c2c528416c9d67 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 10 May 2017 13:59:34 -0500 Subject: [PATCH 2/3] Fix vendor target as to not call "glide install" on every invocation --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8ab1e90d..b318f52ea 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,10 @@ ifndef GLIDE curl https://glide.sh/get | sh endif -vendor: glide glide.yaml +$(GLIDE): + make glide + +vendor: $(GLIDE) glide.yaml glide install glide.lock: glide glide.yaml From 3a1bcc353e214d064d8284718315474ee6ff7433 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 10 May 2017 14:04:09 -0500 Subject: [PATCH 3/3] Add release target in Makefile --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b318f52ea..f614068d4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: glide vendor-update docker pilosa crossbuild install generate statik +.PHONY: glide vendor-update docker pilosa crossbuild install generate statik release GLIDE := $(shell command -v glide 2>/dev/null) STATIK := $(shell command -v statik 2>/dev/null) @@ -39,6 +39,13 @@ pilosa: vendor crossbuild: vendor mkdir -p build/pilosa-$(IDENTIFIER) make pilosa FLAGS="-o build/pilosa-$(IDENTIFIER)/pilosa" + cp {LICENSE,README.md} build/pilosa-$(IDENTIFIER) + tar -cvz -C build -f build/pilosa-$(IDENTIFIER).tar.gz pilosa-$(IDENTIFIER)/ + @echo "Created release build: build/pilosa-$(IDENTIFIER).tar.gz" + +release: + make crossbuild GOOS=linux GOARCH=amd64 + make crossbuild GOOS=darwin GOARCH=amd64 install: vendor go install -ldflags $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa