2014-04-13 13:22:12 -04:00
|
|
|
#include "revision_utils.hpp"
|
|
|
|
|
2014-09-18 18:32:27 -04:00
|
|
|
#include <cstring>
|
|
|
|
|
2014-04-13 13:22:12 -04:00
|
|
|
#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 ())
|
|
|
|
{
|
2015-02-21 19:20:42 -05:00
|
|
|
// fall back to revision passed in if any
|
2014-04-13 13:22:12 -04:00
|
|
|
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 ())
|
|
|
|
{
|
2015-02-21 19:20:42 -05:00
|
|
|
// not CMake build so all we have is revision passed
|
2014-04-13 13:22:12 -04:00
|
|
|
result = revision_from_svn;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return result.trimmed ();
|
|
|
|
}
|
|
|
|
|
2015-02-21 19:20:42 -05:00
|
|
|
QString version ()
|
|
|
|
{
|
|
|
|
#if defined (CMAKE_BUILD)
|
|
|
|
QString v {WSJTX_STRINGIZE (WSJTX_VERSION_MAJOR) "." WSJTX_STRINGIZE (WSJTX_VERSION_MINOR) "." WSJTX_STRINGIZE (WSJTX_VERSION_PATCH)};
|
|
|
|
# if defined (WSJTX_RC)
|
|
|
|
v += "-rc" WSJTX_STRINGIZE (WSJTX_RC);
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
QString v {"Not for Release"};
|
|
|
|
#endif
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2014-04-13 13:22:12 -04:00
|
|
|
QString program_title (QString const& revision)
|
|
|
|
{
|
2015-02-23 10:19:41 -05:00
|
|
|
QString id {QCoreApplication::applicationName () + " v" + QCoreApplication::applicationVersion ()};
|
2014-09-18 18:32:27 -04:00
|
|
|
return id + " " + revision + " by K1JT";
|
2014-04-13 13:22:12 -04:00
|
|
|
}
|