From 7845515f36ef3101236d8390a8393ed322f0345e Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 2 Nov 2015 02:11:34 -0800 Subject: [PATCH] build: Versioning now populated through ldflags --- .gitignore | 1 - Makefile | 12 ++-- appveyor.yml | 3 + build-constants.go | 26 ++++++--- .../{gen-constants.go => gen-ldflags.go} | 55 +++---------------- update-main.go | 4 +- 6 files changed, 36 insertions(+), 65 deletions(-) rename buildscripts/{gen-constants.go => gen-ldflags.go} (51%) diff --git a/.gitignore b/.gitignore index 6b70180ca..64dc5bcae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/build-constants.go **/*.swp cover.out *~ diff --git a/Makefile b/Makefile index 12288e56d..eb15ab3e4 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +LDFLAGS = $(shell go run buildscripts/gen-ldflags.go) + all: install checkdeps: @@ -7,6 +9,7 @@ checkdeps: checkgopath: @echo "Checking if project is at ${GOPATH}" @for miniopath in $(echo ${GOPATH} | sed 's/:/\n/g'); do if [ ! -d ${miniopath}/src/github.com/minio/minio ]; then echo "Project not found in ${miniopath}, please follow instructions provided at https://github.com/minio/minio/blob/master/CONTRIBUTING.md#setup-your-minio-github-repository" && exit 1; fi done + @echo "Setting LDFLAGS: ${LDFLAGS}" getdeps: checkdeps checkgopath @go get -u github.com/golang/lint/golint && echo "Installed golint:" @@ -38,7 +41,7 @@ cyclo: @GO15VENDOREXPERIMENT=1 gocyclo -over 65 *.go @GO15VENDOREXPERIMENT=1 gocyclo -over 65 pkg -build: constants getdeps verifiers +build: getdeps verifiers @echo "Installing minio:" deadcode: @@ -50,11 +53,7 @@ test: build @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/minio/pkg... gomake-all: build - @GO15VENDOREXPERIMENT=1 go install github.com/minio/minio - -constants: - @echo "Generating new build-constants.go" - @GO15VENDOREXPERIMENT=1 go run buildscripts/gen-constants.go + @GO15VENDOREXPERIMENT=1 go build -ldflags $(LDFLAGS) -o $(GOPATH)/bin/minio pkg-add: @GO15VENDOREXPERIMENT=1 govendor add $(PKG) @@ -69,7 +68,6 @@ install: gomake-all clean: @echo "Cleaning up all the generated files:" - @rm -fv build-constants.go @rm -fv cover.out @rm -fv minio @rm -fv minio.test diff --git a/appveyor.yml b/appveyor.yml index acaa2a189..21c46e5d4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,6 +26,9 @@ build_script: - go test -race . - go test github.com/minio/minio/pkg... - go test -race github.com/minio/minio/pkg... + - go run buildscripts/gen-ldflags.go > temp.txt + - set /p LDFLAGS=