- if(committish.isEmpty()) {
- QRegExp rxCommit("distCommittish\\s*=\\s*([0-9a-f]+)");
- if(rxCommit.indexIn(ver) >= 0) committish = rxCommit.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();
+ }
+
+ // generate the contents for version.gen
+ QByteArray contents = QString("QString buildinfo = \"%1,%2,%3,%4,%5,%6,%7,%8\";\n")
+ .arg(basever, descrver, dirty, committish, commitdate, protover, clientneeds, coreneeds)
+ .toAscii();
+
+ QFile gen(target);
+ if (!gen.open(QIODevice::ReadWrite | QIODevice::Text)) {
+ qFatal("%s", qPrintable(QString("Could not write %1!").arg(target)));
+ return EXIT_FAILURE;
+ }
+ QByteArray oldContents = gen.readAll();
+ if (oldContents != contents) { // only touch the file if something changed
+ gen.seek(0);
+ gen.resize(0);
+ gen.write(contents);
+ gen.waitForBytesWritten(10000);