From 3f1b042d6ce2299c62c5fcf21dad1c59d29044f8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 10 Apr 2017 20:24:58 +0300 Subject: [PATCH] Get hash also from git repository. Because we use both hg and git (as mirror) we can get hash of current commit from git too. --HG-- branch : release --- common.pri | 34 +++++++++++++++++++++++++++++ src/app/tape/tape.pro | 28 +++++------------------- src/app/valentina/valentina.pro | 38 +++++---------------------------- src/libs/vmisc/vmisc.pro | 14 ------------ 4 files changed, 44 insertions(+), 70 deletions(-) diff --git a/common.pri b/common.pri index d712a492a..b92f339f3 100644 --- a/common.pri +++ b/common.pri @@ -171,6 +171,40 @@ defineReplace(enable_ccache){ return(true) } +defineReplace(FindBuildRevision){ +CONFIG(debug, debug|release){ + # Debug mode + return(\\\"unknown\\\") +}else{ + # Release mode + + macx{ + HG = /usr/local/bin/hg # Can't defeat PATH variable on Mac OS. + }else { + HG = hg # All other platforms are OK. + } + + #build revision number for using in version + unix { + DVCS_HESH=$$system("$${HG} log -r. --template '{node|short}'") + } else { + # Use escape character before "|" on Windows + DVCS_HESH=$$system($${HG} log -r. --template "{node^|short}") + } + isEmpty(DVCS_HESH){ + DVCS_HESH=$$system("git rev-parse --short HEAD") + isEmpty(DVCS_HESH){ + DVCS_HESH = "unknown" # if we can't find build revision left unknown. + } else { + DVCS_HESH=\\\"Git:$${DVCS_HESH}\\\" + } + } else { + DVCS_HESH=\\\"Hg:$${DVCS_HESH}\\\" + } + return($${DVCS_HESH}) +} +} + # Default prefix. Use for creation install path. DEFAULT_PREFIX = /usr diff --git a/src/app/tape/tape.pro b/src/app/tape/tape.pro index c66bed84b..7459dd71e 100644 --- a/src/app/tape/tape.pro +++ b/src/app/tape/tape.pro @@ -282,10 +282,7 @@ $$enable_ccache() include(warnings.pri) -CONFIG(debug, debug|release){ - # Debug mode - DEFINES += "BUILD_REVISION=\\\"unknown\\\"" -}else{ +CONFIG(release, debug|release){ # Release mode !win32-msvc*:CONFIG += silent DEFINES += V_NO_ASSERT @@ -307,27 +304,12 @@ CONFIG(debug, debug|release){ QMAKE_LFLAGS_RELEASE = } } - - macx{ - HG = /usr/local/bin/hg # Can't defeat PATH variable on Mac OS. - }else { - HG = hg # All other platforms all OK. - } - - #build revision number for using in version - unix { - HG_HESH=$$system("$${HG} log -r. --template '{node|short}'") - } else { - # Use escape character before "|" on Windows - HG_HESH=$$system($${HG} log -r. --template "{node^|short}") - } - isEmpty(HG_HESH){ - HG_HESH = "unknown" # if we can't find build revision left unknown. - } - message("Build revision:" $${HG_HESH}) - DEFINES += "BUILD_REVISION=\\\"$${HG_HESH}\\\"" # Make available build revision number in sources. } +DVCS_HESH=$$FindBuildRevision() +message("Build revision:" $${DVCS_HESH}) +DEFINES += "BUILD_REVISION=$${DVCS_HESH}" # Make available build revision number in sources. + # Path to recource file. win32:RC_FILE = share/resources/tape.rc diff --git a/src/app/valentina/valentina.pro b/src/app/valentina/valentina.pro index f2f41abec..8791d0daf 100644 --- a/src/app/valentina/valentina.pro +++ b/src/app/valentina/valentina.pro @@ -65,13 +65,7 @@ $$enable_ccache() include(warnings.pri) -CONFIG(debug, debug|release){ - # Debug mode - #Calculate latest tag distance and build revision only in release mode. Change number each time requare - #recompilation precompiled headers file. - DEFINES += "LATEST_TAG_DISTANCE=0" - DEFINES += "BUILD_REVISION=\\\"unknown\\\"" -}else{ +CONFIG(release, debug|release){ # Release mode !win32-msvc*:CONFIG += silent DEFINES += V_NO_ASSERT @@ -93,34 +87,12 @@ CONFIG(debug, debug|release){ QMAKE_LFLAGS_RELEASE = } } - - macx{ - HG = /usr/local/bin/hg # Can't defeat PATH variable on Mac OS. - }else { - HG = hg # All other platforms all OK. - } - #latest tag distance number for using in version - HG_DISTANCE=$$system($${HG} log -r. --template '{latesttagdistance}') - isEmpty(HG_DISTANCE){ - HG_DISTANCE = 0 # if we can't find local revision left 0. - } - message("Latest tag distance:" $${HG_DISTANCE}) - DEFINES += "LATEST_TAG_DISTANCE=$${HG_DISTANCE}" # Make available latest tag distance number in sources. - - #build revision number for using in version - unix { - HG_HESH=$$system("$${HG} log -r. --template '{node|short}'") - } else { - # Use escape character before "|" on Windows - HG_HESH=$$system($${HG} log -r. --template "{node^|short}") - } - isEmpty(HG_HESH){ - HG_HESH = "unknown" # if we can't find build revision left unknown. - } - message("Build revision:" $${HG_HESH}) - DEFINES += "BUILD_REVISION=\\\"$${HG_HESH}\\\"" # Make available build revision number in sources. } +DVCS_HESH=$$FindBuildRevision() +message("Build revision:" $${DVCS_HESH}) +DEFINES += "BUILD_REVISION=$${DVCS_HESH}" # Make available build revision number in sources. + # Some extra information about Qt. Can be usefull. message(Qt version: $$[QT_VERSION]) message(Qt is installed in $$[QT_INSTALL_PREFIX]) diff --git a/src/libs/vmisc/vmisc.pro b/src/libs/vmisc/vmisc.pro index b350e51d5..beeadf2e6 100644 --- a/src/libs/vmisc/vmisc.pro +++ b/src/libs/vmisc/vmisc.pro @@ -55,7 +55,6 @@ CONFIG(debug, debug|release){ #Calculate latest tag distance and build revision only in release mode. Change number each time requare #recompilation precompiled headers file. DEFINES += "LATEST_TAG_DISTANCE=0" - DEFINES += "BUILD_REVISION=\\\"unknown\\\"" }else{ # Release mode !win32-msvc*:CONFIG += silent @@ -88,19 +87,6 @@ CONFIG(debug, debug|release){ } message("Latest tag distance:" $${HG_DISTANCE}) DEFINES += "LATEST_TAG_DISTANCE=$${HG_DISTANCE}" # Make available latest tag distance number in sources. - - #build revision number for using in version - unix { - HG_HESH=$$system("$${HG} log -r. --template '{node|short}'") - } else { - # Use escape character before "|" on Windows - HG_HESH=$$system($${HG} log -r. --template "{node^|short}") - } - isEmpty(HG_HESH){ - HG_HESH = "unknown" # if we can't find build revision left unknown. - } - message("Build revision:" $${HG_HESH}) - DEFINES += "BUILD_REVISION=\\\"$${HG_HESH}\\\"" # Make available build revision number in sources. } include (../libs.pri)