mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-10-31 23:57:10 -04:00
241033d49b
all types of build. CMake builds use 'svn info' (the git-svn equivalent is also supported) to get the real latest revision of the workspace that is used to source a build. If the sources are not in VCS workspace (build from source snapshot archive for example) then the $Rev$ svn keyword expansion in mainwindow.cpp is used despite its issues with accuracy. Non-CMake builds use the $Rev$ keyword expansion where possible. If a CMake build is from a VCS workspace with local modifications; a '-dirty' suffix is added to the revision number to denote that. If no revision number information can be found the word 'local' is used as a revision number. The revision specification is used in the WSJT-X "about" box and is sent to PSKReporter.info as part of the local station information (this can be viewed at the statistics page http://pskreporter.info/cgi-bin/pskstats.pl). git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4017 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
81 lines
2.1 KiB
C++
81 lines
2.1 KiB
C++
#include "revision_utils.hpp"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QRegularExpression>
|
|
|
|
#include "svnversion.h"
|
|
|
|
namespace
|
|
{
|
|
QString revision_extract_number (QString const& s)
|
|
{
|
|
QString revision;
|
|
|
|
// try and match a number
|
|
QRegularExpression re {R"(^[$:]\w+: (\d+[^$]*)\$$)"};
|
|
auto match = re.match (s);
|
|
if (match.hasMatch ())
|
|
{
|
|
revision = 'r' + match.captured (1);
|
|
}
|
|
return revision;
|
|
}
|
|
}
|
|
|
|
QString revision (QString const& svn_rev_string)
|
|
{
|
|
QString result;
|
|
auto revision_from_svn = revision_extract_number (svn_rev_string);
|
|
|
|
#if defined (CMAKE_BUILD)
|
|
QString svn_info {":Rev: " WSJTX_STRINGIZE (SVNVERSION) " $"};
|
|
|
|
auto revision_from_svn_info = revision_extract_number (svn_info);
|
|
if (!revision_from_svn_info.isEmpty ())
|
|
{
|
|
// we managed to get the revision number from svn info etc.
|
|
result = revision_from_svn_info;
|
|
}
|
|
else if (!revision_from_svn.isEmpty ())
|
|
{
|
|
// fall back to revision in ths file, this is potentially
|
|
// wrong because svn only updates the id when this file is
|
|
// touched
|
|
//
|
|
// this case gets us a revision when someone builds from a
|
|
// source snapshot or copy
|
|
result = revision_from_svn;
|
|
}
|
|
else
|
|
{
|
|
// match anything
|
|
QRegularExpression re {R"(^[$:]\w+: ([^$]*)\$$)"};
|
|
auto match = re.match (svn_info);
|
|
if (match.hasMatch ())
|
|
{
|
|
result = match.captured (1);
|
|
}
|
|
}
|
|
#else
|
|
if (!revision_from_svn.isEmpty ())
|
|
{
|
|
// not CMake build so all we have is svn revision in this file
|
|
result = revision_from_svn;
|
|
}
|
|
#endif
|
|
if (result.isEmpty ())
|
|
{
|
|
result = "local"; // last resort fall back
|
|
}
|
|
return result.trimmed ();
|
|
}
|
|
|
|
QString program_title (QString const& revision)
|
|
{
|
|
#if defined (CMAKE_BUILD)
|
|
return QCoreApplication::applicationName () + " v" WSJTX_STRINGIZE (WSJTX_VERSION_MAJOR) "." WSJTX_STRINGIZE (WSJTX_VERSION_MINOR) "." WSJTX_STRINGIZE (WSJTX_VERSION_PATCH) " " + revision + " by K1JT";
|
|
#else
|
|
return "WSJT-X v1.4 " + revision + " by K1JT";
|
|
#endif
|
|
}
|