Finally removes Global:: and properly fills Quassel::buildInfo() instead.
Also, recompiles of mod_common are no longer needed for every make.
-version.dist export-subst
+version.inc export-subst
get_target_property(GENVERSION_EXECUTABLE genversion LOCATION)
add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE}
- ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/common/version.gen)
+ ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen)
add_dependencies(genversion_run genversion)
# Decide what to do with icons
#add_subdirectory(pics)
add_subdirectory(i18n)
add_subdirectory(src)
-
-# Make sure version.gen exists before building mod_common
-# TODO: make only main.cpp depend on that! Recompiles suck...
-add_dependencies(mod_common genversion_run)
include_directories(qtui)
endif(WANT_QTCLIENT OR WANT_MONO)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}) # for version.gen
+
# We always add stuff in :/pics
qt4_add_resources(CLIENT_DEPS ../pics/pics.qrc)
if(WANT_CORE)
setup_qt4_variables(NETWORK SCRIPT SQL)
add_executable(quasselcore common/main.cpp ${COMMON_DEPS} ${CORE_DEPS})
+ add_dependencies(quasselcore genversion_run)
set_target_properties(quasselcore PROPERTIES
COMPILE_FLAGS "-DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_CORE"
OUTPUT_NAME ../quasselcore)
if(WANT_QTCLIENT)
setup_qt4_variables(${LINK_DBUS} GUI NETWORK ${LINK_WEBKIT})
add_executable(quasselclient WIN32 common/main.cpp ${COMMON_DEPS} ${CLIENT_DEPS})
- add_dependencies(quasselclient icons)
+ add_dependencies(quasselclient icons genversion_run)
set_target_properties(quasselclient PROPERTIES
COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI"
OUTPUT_NAME ../quasselclient)
if(WANT_MONO)
setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL ${LINK_WEBKIT})
add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS})
- add_dependencies(quassel icons)
+ add_dependencies(quassel icons genversion_run)
set_target_properties(quassel PROPERTIES
COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO"
OUTPUT_NAME ../quassel)
//emit coreConnectionMsg(tr("Synchronizing to core..."));
QVariantMap clientInit;
clientInit["MsgType"] = "ClientInit";
- clientInit["ClientVersion"] = Global::quasselVersion;
+ clientInit["ClientVersion"] = Quassel::buildInfo().fancyVersionString;
clientInit["ClientBuild"] = 860; // FIXME legacy!
- clientInit["ClientDate"] = Global::quasselBuildDate;
- clientInit["ProtocolVersion"] = Global::protocolVersion;
+ clientInit["ClientDate"] = Quassel::buildInfo().buildDate;
+ clientInit["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
clientInit["UseSsl"] = coreConnectionInfo["useSsl"];
#ifndef QT_NO_COMPRESS
clientInit["UseCompression"] = true;
uint ver = 0;
if(!msg.contains("ProtocolVersion") && msg["CoreBuild"].toUInt() >= 732) ver = 1; // legacy!
if(msg.contains("ProtocolVersion")) ver = msg["ProtocolVersion"].toUInt();
- if(ver < Global::clientNeedsProtocol) {
+ if(ver < Quassel::buildInfo().clientNeedsProtocol) {
emit connectionError(tr("<b>The Quassel Core you are trying to connect to is too old!</b><br>"
- "Need at least core/client protocol v%1 to connect.").arg(Global::clientNeedsProtocol));
+ "Need at least core/client protocol v%1 to connect.").arg(Quassel::buildInfo().clientNeedsProtocol));
disconnectFromCore();
return;
}
/** This is called at compile time and generates a suitable version.gen.
* usage: genversion git_root target_file
- *
*/
#include <QDebug>
}
QString gitroot = argv[1];
QString target = argv[2];
- QString version, commit, archivetime;
+ QString basever, protover, clientneeds, coreneeds, descrver, dirty;
+ QString committish, commitdate;
+ // check Git for information if present
if(QFile::exists(gitroot + "/.git")) {
// try to execute git-describe to get a version string
QProcess git;
git.setWorkingDirectory(gitroot);
git.start("git", QStringList() << "describe" << "--long");
if(git.waitForFinished(10000)) {
- QString gitversion = git.readAllStandardOutput();
- if(!gitversion.isEmpty() && !gitversion.contains("fatal")) {
- // seems we have a valid version string, now prettify it...
- // check if the workdir is dirty first
- QString dirty;
- QStringList params = QStringList() << "diff-index" << "--name-only" << "HEAD";
- git.start("git", params);
+ QString descr = git.readAllStandardOutput().trimmed();
+ if(!descr.isEmpty() && !descr.contains("fatal")) {
+ // seems we have a valid git describe string
+ descrver = descr;
+ // check if the workdir is dirty
+ git.start("git", QStringList() << "diff-index" << "--name-only" << "HEAD");
if(git.waitForFinished(10000)) {
if(!git.readAllStandardOutput().isEmpty()) dirty = "*";
}
+ // get a full committish
+ git.start("git", QStringList() << "rev-parse" << "HEAD");
+ if(git.waitForFinished(10000)) {
+ committish = git.readAllStandardOutput().trimmed();
+ }
// Now we do some replacement magic...
- QRegExp rxCheckTag("(.*)-0-g[0-9a-f]+\n$");
- QRegExp rxGittify("(.*)-(\\d+)-g([0-9a-f]+)\n$");
- gitversion.replace(rxCheckTag, QString("\\1%1").arg(dirty));
- gitversion.replace(rxGittify, QString("\\1:git-\\3+\\2%1").arg(dirty));
- if(!gitversion.isEmpty()) version = gitversion;
+ //QRegExp rxCheckTag("(.*)-0-g[0-9a-f]+\n$");
+ //QRegExp rxGittify("(.*)-(\\d+)-g([0-9a-f]+)\n$");
+ //gitversion.replace(rxCheckTag, QString("\\1%1").arg(dirty));
+ //gitversion.replace(rxGittify, QString("\\1:git-\\3+\\2%1").arg(dirty));
}
}
}
- if(version.isEmpty()) {
- // hmm, Git failed... let's check for version.dist instead
- QFile dist(gitroot + "/version.dist");
- if(dist.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QRegExp rxCommit("(^[0-9a-f]+)");
- QRegExp rxTimestamp("(^[0-9]+)");
- if(rxCommit.indexIn(dist.readLine()) > -1) commit = rxCommit.cap(1);
- if(rxTimestamp.indexIn(dist.readLine()) > -1) archivetime = rxTimestamp.cap(1);
- dist.close();
+
+ // parse version.inc
+ QFile verfile(gitroot + "/version.inc");
+ if(verfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QString ver = verfile.readAll();
+
+ QRegExp rxBasever("baseVersion\\s*=\\s*\"(.*)\";");
+ if(rxBasever.indexIn(ver) >= 0)
+ basever = rxBasever.cap(1);
+
+ QRegExp rxProtover("protocolVersion\\s*=\\s*(\\d+)");
+ if(rxProtover.indexIn(ver) >= 0)
+ protover = rxProtover.cap(1);
+
+ QRegExp rxClientneeds("clientNeedsProtocol\\s*=\\s*(\\d+)");
+ if(rxClientneeds.indexIn(ver) >= 0)
+ clientneeds = rxClientneeds.cap(1);
+
+ QRegExp rxCoreneeds("coreNeedsProtocol\\s*=\\s*(\\d+)");
+ if(rxCoreneeds.indexIn(ver) >= 0)
+ coreneeds = rxCoreneeds.cap(1);
+
+ if(committish.isEmpty()) {
+ QRegExp rxCommit("distCommittish\\s*=\\s*([0-9a-f]+)");
+ if(rxCommit.indexIn(ver) >= 0) committish = rxCommit.cap(1);
}
+
+ QRegExp rxTimestamp("distCommitDate\\s*=\\s*([0-9]+)");
+ if(rxTimestamp.indexIn(ver) >= 0) commitdate = rxTimestamp.cap(1);
+ verfile.close();
}
+
// ok, create our version.gen now
QFile gen(target);
if(!gen.open(QIODevice::WriteOnly | QIODevice::Text)) {
qFatal("%s", qPrintable(QString("Could not write %1!").arg(target)));
- return 255;
+ return EXIT_FAILURE;
}
- gen.write(QString("quasselGeneratedVersion = \"%1\";\n"
- "quasselBuildDate = \"%2\";\n"
- "quasselBuildTime = \"%3\";\n"
- "quasselCommit = \"%4\";\n"
- "quasselArchiveDate = %5;\n")
- .arg(version).arg(__DATE__).arg(__TIME__).arg(commit).arg(archivetime.toUInt()).toAscii());
+ gen.write(QString("QString buildinfo = \"%1,%2,%3,%4,%5,%6,%7,%8\";")
+ .arg(basever, descrver, dirty, committish, commitdate, protover, clientneeds, coreneeds).toAscii());
gen.close();
return EXIT_SUCCESS;
}
MonolithicApplication app(argc, argv);
# endif
+# include "version.gen"
+ buildinfo.append(QString(",%1,%2").arg(__DATE__, __TIME__));
+ app.setupBuildInfo(buildinfo);
+
if(!app.init()) return EXIT_FAILURE;
return app.exec();
}
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
registerMetaTypes();
- setupBuildInfo();
- Global::setupVersion();
setupTranslations();
QCoreApplication::setApplicationName(buildInfo().applicationName);
qApp->installTranslator(quasselTranslator);
}
-void Quassel::setupBuildInfo() {
+void Quassel::setupBuildInfo(const QString &generated) {
_buildInfo.applicationName = "Quassel IRC";
_buildInfo.coreApplicationName = "Quassel Core";
_buildInfo.clientApplicationName = "Quassel Client";
_buildInfo.organizationName = "Quassel Project";
_buildInfo.organizationDomain = "quassel-irc.org";
-/*
-# include "version.inc"
-# include "version.gen"
-
- if(quasselGeneratedVersion.isEmpty()) {
- if(quasselCommit.isEmpty())
- quasselVersion = QString("v%1 (unknown rev)").arg(quasselBaseVersion);
- else
- quasselVersion = QString("v%1 (dist-%2, %3)").arg(quasselBaseVersion).arg(quasselCommit.left(7))
- .arg(QDateTime::fromTime_t(quasselArchiveDate).toLocalTime().toString("yyyy-MM-dd"));
+
+ QStringList gen = generated.split(',');
+ Q_ASSERT(gen.count() == 10);
+ _buildInfo.baseVersion = gen[0];
+ _buildInfo.generatedVersion = gen[1];
+ _buildInfo.isSourceDirty = !gen[2].isEmpty();
+ _buildInfo.commitHash = gen[3];
+ _buildInfo.commitDate = gen[4].toUInt();
+ _buildInfo.protocolVersion = gen[5].toUInt();
+ _buildInfo.clientNeedsProtocol = gen[6].toUInt();
+ _buildInfo.coreNeedsProtocol = gen[7].toUInt();
+ _buildInfo.buildDate = QString("%1 %2").arg(gen[8], gen[9]);
+ // create a nice version string
+ if(_buildInfo.generatedVersion.isEmpty()) {
+ if(!_buildInfo.commitHash.isEmpty()) {
+ // dist version
+ _buildInfo.plainVersionString = QString("v%1 (dist-%2)")
+ .arg(_buildInfo.baseVersion)
+ .arg(_buildInfo.commitHash.left(7));
+ _buildInfo.fancyVersionString = QString("v%1 (dist-<a href=\"http://git.quassel-irc.org/%3\">%2</a>)")
+ .arg(_buildInfo.baseVersion)
+ .arg(_buildInfo.commitHash.left(7))
+ .arg(_buildInfo.commitHash);
+ } else {
+ // we only have a base version :(
+ _buildInfo.plainVersionString = QString("v%1 (unknown rev)").arg(_buildInfo.baseVersion);
+ }
} else {
- QStringList parts = quasselGeneratedVersion.split(':');
- quasselVersion = QString("v%1").arg(parts[0]);
- if(parts.count() >= 2) quasselVersion.append(QString(" (%1)").arg(parts[1]));
+ // analyze what we got from git-describe
+ QRegExp rx("(.*)-(\\d+)-g([0-9a-f]+)$");
+ if(rx.exactMatch(_buildInfo.generatedVersion)) {
+ QString distance = rx.cap(2) == "0" ? QString() : QString(" [+%1]").arg(rx.cap(2));
+ _buildInfo.plainVersionString = QString("v%1%2 (git-%3%4)")
+ .arg(rx.cap(1), distance, rx.cap(3))
+ .arg(_buildInfo.isSourceDirty ? "*" : "");
+ if(!_buildInfo.commitHash.isEmpty()) {
+ _buildInfo.fancyVersionString = QString("v%1%2 (git-<a href=\"http://git.quassel-irc.org/%5\">%3</a>%4)")
+ .arg(rx.cap(1), distance, rx.cap(3))
+ .arg(_buildInfo.isSourceDirty ? "*" : "")
+ .arg(_buildInfo.commitHash);
+ }
+ } else {
+ _buildInfo.plainVersionString = QString("v%1 (invalid rev)").arg(_buildInfo.baseVersion);
+ }
}
- quasselBuildDate = __DATE__;
- quasselBuildTime = __TIME__;
- */
+ if(_buildInfo.fancyVersionString.isEmpty())
+ _buildInfo.fancyVersionString = _buildInfo.plainVersionString;
}
//! Signal handler for graceful shutdown.
exit(27);
#endif /* BUILD_CRASHHANDLER */
}
-
-// FIXME temporary
-
-void Global::setupVersion() {
-
- # include "version.inc"
- # include "version.gen"
-
- if(quasselGeneratedVersion.isEmpty()) {
- if(quasselCommit.isEmpty())
- quasselVersion = QString("v%1 (unknown rev)").arg(quasselBaseVersion);
- else
- quasselVersion = QString("v%1 (dist-%2, %3)").arg(quasselBaseVersion).arg(quasselCommit.left(7))
- .arg(QDateTime::fromTime_t(quasselArchiveDate).toLocalTime().toString("yyyy-MM-dd"));
- } else {
- QStringList parts = quasselGeneratedVersion.split(':');
- quasselVersion = QString("v%1").arg(parts[0]);
- if(parts.count() >= 2) quasselVersion.append(QString(" (%1)").arg(parts[1]));
- }
- quasselBuildDate = __DATE__;
- quasselBuildTime = __TIME__;
-}
-
-QString Global::quasselVersion;
-QString Global::quasselBaseVersion;
-QString Global::quasselGeneratedVersion;
-QString Global::quasselBuildDate;
-QString Global::quasselBuildTime;
-QString Global::quasselCommit;
-uint Global::quasselArchiveDate;
-uint Global::protocolVersion;
-uint Global::clientNeedsProtocol;
-uint Global::coreNeedsProtocol;
};
struct BuildInfo {
- QString version;
+ QString fancyVersionString; // clickable rev
+ QString plainVersionString; // no <a> tag
+
QString baseVersion;
QString generatedVersion;
- QString buildDate;
- QString buildTime;
QString commitHash;
- uint archiveDate;
+ uint commitDate;
+ QString buildDate;
+ bool isSourceDirty;
uint protocolVersion;
uint clientNeedsProtocol;
uint coreNeedsProtocol;
QString organizationDomain;
};
+ void setupBuildInfo(const QString &generated);
+
virtual ~Quassel();
static inline const BuildInfo & buildInfo();
private:
- void setupBuildInfo();
void setupTranslations();
void registerMetaTypes();
static bool _initialized;
};
-// FIXME temporary
-namespace Global {
- extern QString quasselVersion;
- extern QString quasselBaseVersion;
- extern QString quasselBuildDate;
- extern QString quasselBuildTime;
- extern QString quasselCommit;
- extern uint quasselArchiveDate;
- extern uint protocolVersion;
-
- extern uint clientNeedsProtocol; //< Minimum protocol version the client needs
- extern uint coreNeedsProtocol; //< Minimum protocol version the core needs
-
- extern QString quasselGeneratedVersion; //< This is possibly set in version.gen
-
- void setupVersion();
-};
-
const Quassel::BuildInfo & Quassel::buildInfo() { return _buildInfo; }
Quassel::RunMode Quassel::runMode() { return _runMode; }
void Quassel::setRunMode(Quassel::RunMode mode) { _runMode = mode; }
uint port = Quassel::optionValue("port").toUInt();
if(_server.listen(QHostAddress::Any, port)) {
- quInfo() << "Listening for GUI clients on IPv6 port" << _server.serverPort() << "using protocol version" << Global::protocolVersion;
+ quInfo() << "Listening for GUI clients on IPv6 port" << _server.serverPort()
+ << "using protocol version" << Quassel::buildInfo().protocolVersion;
success = true;
}
if(_v6server.listen(QHostAddress::AnyIPv6, port)) {
- quInfo() << "Listening for GUI clients on IPv4 port" << _v6server.serverPort() << "using protocol version" << Global::protocolVersion;
+ quInfo() << "Listening for GUI clients on IPv4 port" << _v6server.serverPort()
+ << "using protocol version" << Quassel::buildInfo().protocolVersion;
success = true;
}
uint ver = 0;
if(!msg.contains("ProtocolVersion") && msg["ClientBuild"].toUInt() >= 732) ver = 1; // FIXME legacy
if(msg.contains("ProtocolVersion")) ver = msg["ProtocolVersion"].toUInt();
- if(ver < Global::coreNeedsProtocol) {
+ if(ver < Quassel::buildInfo().coreNeedsProtocol) {
reply["MsgType"] = "ClientInitReject";
reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
"This core needs at least client/core protocol version %1.<br>"
- "Please consider upgrading your client.").arg(Global::coreNeedsProtocol);
+ "Please consider upgrading your client.").arg(Quassel::buildInfo().coreNeedsProtocol);
SignalProxy::writeDataToDevice(socket, reply);
quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting."));
socket->close(); return;
}
- reply["CoreVersion"] = Global::quasselVersion;
- reply["CoreDate"] = Global::quasselBuildDate;
+ reply["CoreVersion"] = Quassel::buildInfo().fancyVersionString;
+ reply["CoreDate"] = Quassel::buildInfo().buildDate;
reply["CoreBuild"] = 860; // FIXME legacy
- reply["ProtocolVersion"] = Global::protocolVersion;
+ reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
// TODO: Make the core info configurable
int uptime = startTime().secsTo(QDateTime::currentDateTime().toUTC());
int updays = uptime / 86400; uptime %= 86400;
int upmins = uptime / 60;
reply["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
"Built: %2<br>"
- "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate)
+ "Up %3d%4h%5m (since %6)").arg(Quassel::buildInfo().fancyVersionString)
+ .arg(Quassel::buildInfo().buildDate)
.arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate));
#ifdef HAVE_SSL
QVariantMap CoreCoreInfo::coreData() const {
QVariantMap data;
- data["quasselVersion"] = Global::quasselVersion;
- data["quasselBuildDate"] = Global::quasselBuildDate;
+ data["quasselVersion"] = Quassel::buildInfo().fancyVersionString;
+ data["quasselBuildDate"] = Quassel::buildInfo().buildDate;
data["startTime"] = Core::instance()->startTime();
data["sessionConnectedClients"] = _coreSession->signalProxy()->peerCount();
return data;
Q_UNUSED(target)
if(ctcptype == CtcpQuery) {
reply(nickFromMask(prefix), "VERSION", QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org")
- .arg(Global::quasselVersion).arg(Global::quasselBuildDate));
+ .arg(Quassel::buildInfo().plainVersionString)
+ .arg(Quassel::buildInfo().buildDate));
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP VERSION request by %1").arg(prefix));
} else {
// display Version answer
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <QDateTime>
+
#include "aboutdlg.h"
#include "icon.h"
#include "iconloader.h"
ui.setupUi(this);
ui.quasselLogo->setPixmap(DesktopIcon("quassel", IconLoader::SizeHuge));
- ui.versionLabel->setText(QString(tr("<b>Version %1</b><br>Protocol version: %2<br>Built: %3 %4")).arg(Global::quasselVersion)
- .arg(Global::protocolVersion)
- .arg(Global::quasselBuildDate).arg(Global::quasselBuildTime));
+ ui.versionLabel->setText(QString(tr("<b>Version:</b> %1<br><b>Protocol version:</b> %2<br><b>Built:</b> %3"))
+ .arg(Quassel::buildInfo().fancyVersionString)
+ .arg(Quassel::buildInfo().protocolVersion)
+ .arg(Quassel::buildInfo().buildDate));
ui.aboutTextBrowser->setHtml(about());
ui.authorTextBrowser->setHtml(authors());
ui.contributorTextBrowser->setHtml(contributors());
#include "coreinfodlg.h"
+#include <QDateTime>
+
#include "client.h"
#include "signalproxy.h"
void CoreInfoDlg::coreInfoAvailable() {
ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString());
- ui.labelCoreBuildDate->setText(_coreInfo["quasselBuildDate"].toString());
+ ui.labelCoreBuildDate->setText(QDateTime::fromTime_t(_coreInfo["quasselBuildDate"].toUInt()).toLocalTime().toString());
ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt());
updateUptime();
startTimer(1000);
void CoreInfoDlg::updateUptime() {
QDateTime startTime = _coreInfo["startTime"].toDateTime();
-
+
int uptime = startTime.secsTo(QDateTime::currentDateTime().toUTC());
int updays = uptime / 86400; uptime %= 86400;
int uphours = uptime / 3600; uptime %= 3600;
+++ /dev/null
-$Format:%H$
-$Format:%at$
-// Versioning, should be kept current :)
-// This is included in main.cpp
-
//! This is the fallback version number in case we can't autogenerate one
-quasselBaseVersion = "0.3.0";
-protocolVersion = 5; //< Version of the client/core protocol
+baseVersion = "0.3.0";
+protocolVersion = 5; //< Version of the client/core protocol
coreNeedsProtocol = 5; //< Minimum protocol version the core needs
clientNeedsProtocol = 5; //< Minimum protocol version the client needs
+
+distCommittish = $Format:%H$
+distCommitDate = $Format:%at$