From 1f4bb2d435de7b51819162ac3c11f366f0c83757 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Thu, 16 Jan 2020 13:58:18 -0500 Subject: [PATCH] Clean up build information and version interface. This removes git dependencies from everything except for version.cpp, and removes the associated interfaces in version.h. Since the full version string contains the branch and revision number where applicable, the build information no longer needs to report branch and revision separately. It also now queries version.cpp for a more consistent and reliable build time. Debug output of build information is also now more consistent with less redundant code. --- oscar/SleepLib/common.cpp | 18 ++++++++---------- oscar/SleepLib/common.h | 2 +- oscar/aboutdialog.cpp | 10 +--------- oscar/main.cpp | 14 +++++++++----- oscar/version.cpp | 22 +++++++++++----------- oscar/version.h | 5 +++-- 6 files changed, 33 insertions(+), 38 deletions(-) diff --git a/oscar/SleepLib/common.cpp b/oscar/SleepLib/common.cpp index 64660915..29964e7d 100644 --- a/oscar/SleepLib/common.cpp +++ b/oscar/SleepLib/common.cpp @@ -185,16 +185,9 @@ QString getGraphicsEngine() QStringList buildInfo; -QStringList makeBuildInfo (QString relinfo, QString forcedEngine){ - buildInfo << (STR_AppName + " " + getVersion() + " " + relinfo); - buildInfo << (QObject::tr("Built with Qt") + " " + QT_VERSION_STR + " on " + __DATE__ + " " + __TIME__); - QString branch = ""; - if (gitBranch() != "master") { - branch = QObject::tr("Branch:") + " " + gitBranch() + ", "; - } - buildInfo << branch + (QObject::tr("Revision")) + " " + gitRevision(); - if (getAppName() != STR_AppName) // Report any non-standard app key - buildInfo << (QObject::tr("App key:") + " " + getAppName()); +QStringList makeBuildInfo (QString forcedEngine){ + // application name and version has already been added + buildInfo << (QObject::tr("Built with Qt %1 on %2").arg(QT_VERSION_STR).arg(getBuildDateTime())); buildInfo << QString(""); buildInfo << (QObject::tr("Operating system:") + " " + QSysInfo::prettyProductName()); buildInfo << (QObject::tr("Graphics Engine:") + " " + getOpenGLVersionString()); @@ -202,6 +195,11 @@ QStringList makeBuildInfo (QString relinfo, QString forcedEngine){ if (forcedEngine != "") buildInfo << forcedEngine; + buildInfo << QString(""); + if (getAppName() != STR_AppName) // Report any non-standard app key + buildInfo << (QObject::tr("App key:") + " " + getAppName()); + // Data directory will always be added, later. + return buildInfo; } diff --git a/oscar/SleepLib/common.h b/oscar/SleepLib/common.h index 1815a829..bb111ade 100644 --- a/oscar/SleepLib/common.h +++ b/oscar/SleepLib/common.h @@ -44,7 +44,7 @@ QString getGraphicsEngine(); QString getOpenGLVersionString(); float getOpenGLVersion(); -QStringList makeBuildInfo(QString relinfo, QString forcedEngine); +QStringList makeBuildInfo(QString forcedEngine); QStringList getBuildInfo(); QStringList addBuildInfo (QString value); diff --git a/oscar/aboutdialog.cpp b/oscar/aboutdialog.cpp index 2458562c..093a7a63 100644 --- a/oscar/aboutdialog.cpp +++ b/oscar/aboutdialog.cpp @@ -30,16 +30,8 @@ AboutDialog::AboutDialog(QWidget *parent) : ui->relnotesText->setHtml(getRelnotes()); ui->versionLabel->setText(""); -// QString gitrev = gitRevision(); -// -// if (!gitrev.isEmpty()) { -// gitrev = tr("Revision: %1").arg(QString("%1").arg(gitrev))+"
" -// +tr("Branch: %1").arg(QString("%1").arg(gitBranch()))+"
" -// +tr("Build Date: %1").arg(__DATE__)+"
" -// +tr("Graphics Engine: %1").arg(getGraphicsEngine()); -// } - QString path = GetAppData(); + // TODO: consider replacing gitrev below with a link or button to the System Information window QString text = /* gitrev + */ "

"+tr("Show data folder")+""; ui->infoLabel->setText(text); diff --git a/oscar/main.cpp b/oscar/main.cpp index d3f98090..57a1d7ec 100644 --- a/oscar/main.cpp +++ b/oscar/main.cpp @@ -340,14 +340,19 @@ int main(int argc, char *argv[]) { initializeLogger(); QThread::msleep(50); // Logger takes a little bit to catch up + qDebug().noquote() << "OSCAR starting" << QDateTime::currentDateTime().toString(); + #ifdef QT_DEBUG QString relinfo = " debug"; #else QString relinfo = ""; #endif relinfo = "("+QSysInfo::kernelType()+" "+QSysInfo::currentCpuArchitecture()+relinfo+")"; - qDebug() << "OSCAR starting" << QDateTime::currentDateTime(); - qDebug().noquote() << STR_AppName << getVersion() << relinfo << "Built with Qt" << QT_VERSION_STR << __DATE__ << __TIME__; + relinfo = STR_AppName + " " + getVersion() + " " + relinfo; + + qDebug().noquote() << relinfo; + qDebug().noquote() << "Built with Qt" << QT_VERSION_STR << "on" << getBuildDateTime(); + addBuildInfo(relinfo); // immediately add it to the build info that's accessible from the UI SetDateFormat(); @@ -365,7 +370,7 @@ int main(int argc, char *argv[]) { // Moved buildInfo calls to after translation is available as makeBuildInfo includes tr() calls - QStringList info = makeBuildInfo(relinfo, forcedEngine); + QStringList info = makeBuildInfo(forcedEngine); for (int i = 0; i < info.size(); ++i) qDebug().noquote() << info.at(i); @@ -476,9 +481,8 @@ int main(int argc, char *argv[]) { } // The folder doesn't exist else qDebug() << "AppData folder already exists, so ..."; - qDebug() << "Using " + GetAppData() + " as OSCAR data folder"; + qDebug().noquote() << "Using " + GetAppData() + " as OSCAR data folder"; - addBuildInfo(""); QString path = GetAppData(); addBuildInfo(QObject::tr("Data directory:") + " " + path + ""); diff --git a/oscar/version.cpp b/oscar/version.cpp index faf97a04..e19b275d 100644 --- a/oscar/version.cpp +++ b/oscar/version.cpp @@ -25,23 +25,18 @@ const QString PlatformString = "Linux"; const QString PlatformString = "Haiku"; #endif - -const QString & gitRevision() -{ - return GIT_REVISION; -} -const QString & gitBranch() -{ - return GIT_BRANCH; -} +// Technically this is the date and time that version.cpp was compiled, but since +// it gets recompiled whenever git_info.h changes, it's about as close as we can +// come without forcing recompiles every single build. +static const QString s_BuildDateTime = __DATE__ " " __TIME__; QString getPrereleaseSuffix() { QString suffix; // Append branch if there is a branch specified - if (gitBranch() != "master") { - suffix += "-"+gitBranch(); + if (GIT_BRANCH != "master") { + suffix += "-"+GIT_BRANCH; } // Append "-test" if not release or release candidate @@ -54,6 +49,11 @@ QString getPrereleaseSuffix() return suffix; } +const QString & getBuildDateTime() +{ + return s_BuildDateTime; +} + // TODO: add preprocessor macros to build full version number including build metadata, accounting for tarball/non-git builds. static const Version s_Version(VERSION "+" + GIT_BRANCH + "-" + GIT_REVISION); diff --git a/oscar/version.h b/oscar/version.h index b037193b..1e7484ef 100644 --- a/oscar/version.h +++ b/oscar/version.h @@ -51,8 +51,9 @@ protected: //!brief Get the current version of the application. const Version & getVersion(); +//!brief Get the date and time of the application was built. +const QString & getBuildDateTime(); + QString getPrereleaseSuffix(); -const QString & gitRevision(); -const QString & gitBranch(); #endif // VERSION_H