From 86ffa74047ae84c29024db23451f7fa6cb8ac96f Mon Sep 17 00:00:00 2001 From: Markus Zehnder Date: Fri, 2 Oct 2020 18:32:36 +0200 Subject: [PATCH] fix: Version information if built in Buildroot The Buildroot custom package build used the wrong version information from remote-os instead of the module's git repository. Since the git metadata information is not available during Buildroot build, a QMake parameter is used instead. --- openhab.pro | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/openhab.pro b/openhab.pro index eaa26ec..47600d9 100755 --- a/openhab.pro +++ b/openhab.pro @@ -2,10 +2,24 @@ TEMPLATE = lib CONFIG += plugin QT += core quick network -# Plugin VERSION -GIT_HASH = "$$system(git log -1 --format="%H")" -GIT_BRANCH = "$$system(git rev-parse --abbrev-ref HEAD)" -GIT_VERSION = "$$system(git describe --match "v[0-9]*" --tags HEAD --always)" +# === Version and build information =========================================== +# If built in Buildroot use custom package version, otherwise Git +isEmpty(YIO_BUILD_VERSION) { + GIT_VERSION = "$$system(git describe --match "v[0-9]*" --tags HEAD --always)" + GIT_HASH = "$$system(git log -1 --format="%H")" + GIT_BRANCH = "$$system(git rev-parse --abbrev-ref HEAD)" +} else { + GIT_VERSION = $$YIO_BUILD_VERSION + contains(GIT_VERSION, "^v?(0|[1-9]\d*)\..*") { + # (simplified) version string = regular release + GIT_HASH = "" + GIT_BRANCH = "master" + } else { + # git hash as version = custom build + GIT_HASH = $$YIO_BUILD_VERSION + GIT_BRANCH = "" + } +} OH_VERSION = $$replace(GIT_VERSION, v, "") DEFINES += PLUGIN_VERSION=\\\"$$OH_VERSION\\\" @@ -16,6 +30,8 @@ win32 { } else { BUILDDATE=$$system(date +"%Y-%m-%dT%H:%M:%S") } +# ============================================================================= + CONFIG(debug, debug|release) { DEBUG_BUILD = true } else {