From 191bc3cd8df2f90783a3bd548fe7c1cd459b1620 Mon Sep 17 00:00:00 2001 From: Nicolas PLANEL Date: Thu, 2 Nov 2017 02:28:48 +1100 Subject: [PATCH] build : versioning and tainted build version Signed-off-by: Nicolas PLANEL --- Makefile | 8 +++++--- skydive.go | 4 +++- version/version.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 818d267b05..1f6816a80c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -VERSION?=0.13.0 +VERSION_CMD='define="";version=`git rev-parse --verify HEAD`;tagname=`git show-ref --tags | grep $$version`;if [ -n "$$tagname" ]; then define=`echo $$tagname | awk -F "/" "{print \\$$NF}"`;else define=`printf "%.12s" $$version`;fi;tainted=`git ls-files -m | wc -l`;if [ "$$tainted" -gt 0 ]; then define="$${define}-tainted";fi;echo "$$define"' +VERSION?=$(shell sh -c $(VERSION_CMD)) +$(info ${VERSION}) # really Basic Makefile for Skydive export GO15VENDOREXPERIMENT=1 @@ -49,12 +51,12 @@ all: install gofmt -w -s statics/bindata.go .compile: - ${GOPATH}/bin/govendor install ${GOFLAGS} ${GOTAGS} ${VERBOSE_FLAGS} +local + ${GOPATH}/bin/govendor install -ldflags="-X github.com/skydive-project/skydive/version.Version=${VERSION}" ${GOFLAGS} ${GOTAGS} ${VERBOSE_FLAGS} +local install: govendor genlocalfiles dpdk.build contribs .compile build: govendor genlocalfiles dpdk.build contribs - ${GOPATH}/bin/govendor build ${GOFLAGS} ${GOTAGS} ${VERBOSE_FLAGS} +local + ${GOPATH}/bin/govendor build -ldflags="-X github.com/skydive-project/skydive/version.Version=${VERSION}" ${GOFLAGS} ${GOTAGS} ${VERBOSE_FLAGS} +local static: govendor genlocalfiles rm -f $$GOPATH/bin/skydive diff --git a/skydive.go b/skydive.go index b88c32902e..f433503fb8 100644 --- a/skydive.go +++ b/skydive.go @@ -22,7 +22,9 @@ package main -import "github.com/skydive-project/skydive/cmd" +import ( + "github.com/skydive-project/skydive/cmd" +) func main() { cmd.RootCmd.Execute() diff --git a/version/version.go b/version/version.go index 86628b4eb2..469c29b16b 100644 --- a/version/version.go +++ b/version/version.go @@ -11,7 +11,7 @@ import ( var Package = "github.com/skydive-project/skydive" // Version indicates which version of the binary is running. -var Version = "v0.13.0" +var Version = "unknown" // FprintVersion outputs the version string to the writer, in the following // format, followed by a newline: