Rework Version and Sub-version setup.
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Mon, 15 May 2017 21:42:46 +0000 (23:42 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Mon, 15 May 2017 21:42:46 +0000 (23:42 +0200)
Makefile
main.go

index 210b44b..5a9646e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,18 @@
 # Makefile used to build XDS daemon Web Server
 
+# Application Version
+VERSION := 0.0.1
+
 # Syncthing version to install
-SYNCTHING_VERSION = 0.14.25
+SYNCTHING_VERSION = 0.14.27
 SYNCTHING_INOTIFY_VERSION = 0.8.5
 
+
 # Retrieve git tag/commit to set sub-version string
-ifeq ($(origin VERSION), undefined)
-       VERSION := $(shell git describe --tags --always | sed 's/^v//')
-       ifeq ($(VERSION), )
-               VERSION=unknown-dev
+ifeq ($(origin SUB_VERSION), undefined)
+       SUB_VERSION := $(shell git describe --tags --always | sed 's/^v//')
+       ifeq ($(SUB_VERSION), )
+               SUB_VERSION=unknown-dev
        endif
 endif
 
@@ -42,8 +46,8 @@ all: build webapp
 build: xds
 
 xds:vendor scripts
-       @echo "### Build XDS server (version $(VERSION))";
-       @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-server -ldflags "-X main.AppVersionGitTag=$(VERSION)" .
+       @echo "### Build XDS server (version $(VERSION), subversion $(SUB_VERSION))";
+       @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-server -ldflags "-X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" .
 
 test: tools/glide
        go test --race $(shell ./tools/glide novendor)
@@ -105,8 +109,9 @@ tools/syncthing:
 .PHONY: help
 help:
        @echo "Main supported rules:"
-       @echo "  build               (default)"
-       @echo "  build/xds"
+       @echo "  all                (default)"
+       @echo "  build"
+       @echo "  install"
        @echo "  clean"
        @echo "  distclean"
        @echo ""
diff --git a/main.go b/main.go
index 6561785..40617d1 100644 (file)
--- a/main.go
+++ b/main.go
@@ -15,7 +15,6 @@ import (
 const (
        appName        = "xds-server"
        appDescription = "X(cross) Development System Server is a web server that allows to remotely cross build applications."
-       appVersion     = "0.0.1"
        appCopyright   = "Apache-2.0"
        appUsage       = "X(cross) Development System Server"
 )
@@ -24,9 +23,12 @@ var appAuthors = []cli.Author{
        cli.Author{Name: "Sebastien Douheret", Email: "sebastien@iot.bzh"},
 }
 
-// AppVersionGitTag is the git tag id added to version string
-// Should be set by compilation -ldflags "-X main.AppVersionGitTag=xxx"
-var AppVersionGitTag = "unknown-dev"
+// AppVersion is the version of this application
+var AppVersion = "?.?.?"
+
+// AppSubVersion is the git tag id added to version string
+// Should be set by compilation -ldflags "-X main.AppSubVersion=xxx"
+var AppSubVersion = "unknown-dev"
 
 // Web server main routine
 func webServer(ctx *cli.Context) error {
@@ -58,12 +60,12 @@ func main() {
        app.Name = appName
        app.Description = appDescription
        app.Usage = appUsage
-       app.Version = appVersion + " (" + AppVersionGitTag + ")"
+       app.Version = AppVersion + " (" + AppSubVersion + ")"
        app.Authors = appAuthors
        app.Copyright = appCopyright
        app.Metadata = make(map[string]interface{})
-       app.Metadata["version"] = appVersion
-       app.Metadata["git-tag"] = AppVersionGitTag
+       app.Metadata["version"] = AppVersion
+       app.Metadata["git-tag"] = AppSubVersion
        app.Metadata["logger"] = log
 
        app.Flags = []cli.Flag{