Hi,
ok, if I commit the attached patch to automoc? (see subject :-) )
One question: should I regenerate all moc files once people update to this
version or not? The former is very safe but results in a full recompilation of
everything, the latter is reasonably safe, but still results in a change to
all automoc_<target>.cpp files => relinking of all targets.
--
________________________________________________________
Matthias Kretz (Germany) <><
http://Vir.homelinux.org/
[EMAIL PROTECTED], [EMAIL PROTECTED],
[EMAIL PROTECTED]
Index: kde4automoc.cpp
===================================================================
--- kde4automoc.cpp (revision 842595)
+++ kde4automoc.cpp (working copy)
@@ -58,6 +58,7 @@
private:
void dotFilesCheck(bool);
+ void lazyInitMocDefinitions();
void lazyInit();
bool touch(const QString &filename);
bool generateMoc(const QString &sourceFile, const QString &mocFileName);
@@ -118,7 +119,7 @@
AutoMoc::AutoMoc()
: verbose(!qgetenv("VERBOSE").isEmpty()), cerr(stderr), cout(stdout), failed(false),
- automocCppChanged(false), doTouch(false)
+ automocCppChanged(false), generateAll(false), doTouch(false)
{
const QByteArray colorEnv = qgetenv("COLOR");
cmakeEchoColorArgs << QLatin1String("-E") << QLatin1String("cmake_echo_color")
@@ -126,18 +127,13 @@
<< QLatin1String("--bold");
}
-void AutoMoc::lazyInit()
+void AutoMoc::lazyInitMocDefinitions()
{
- const QStringList &args = QCoreApplication::arguments();
- mocExe = args[4];
- cmakeExecutable = args[5];
-
- if (args.size() > 6) {
- if (args[6] == QLatin1String("--touch")) {
- doTouch = true;
- }
+ static bool done = false;
+ if (done) {
+ return;
}
-
+ done = true;
QByteArray line = dotFiles.readLine();
dotFilesCheck(line == "MOC_COMPILE_DEFINITIONS:\n");
line = dotFiles.readLine().trimmed();
@@ -159,8 +155,23 @@
}
}
}
+}
- line = dotFiles.readLine();
+void AutoMoc::lazyInit()
+{
+ const QStringList &args = QCoreApplication::arguments();
+ mocExe = args[4];
+ cmakeExecutable = args[5];
+
+ if (args.size() > 6) {
+ if (args[6] == QLatin1String("--touch")) {
+ doTouch = true;
+ }
+ }
+
+ lazyInitMocDefinitions();
+
+ QByteArray line = dotFiles.readLine();
dotFilesCheck(line == "MOC_INCLUDES:\n");
line = dotFiles.readLine().trimmed();
const QStringList &incPaths = QString::fromUtf8(line).split(';', QString::SkipEmptyParts);
@@ -241,8 +252,6 @@
builddir += '/';
}
- generateAll = !outfile.exists();
-
dotFiles.setFileName(args[1] + QLatin1String(".files"));
dotFiles.open(QIODevice::ReadOnly | QIODevice::Text);
@@ -250,6 +259,24 @@
dotFilesCheck(line == "SOURCES:\n");
const QStringList &sourceFiles = QString::fromUtf8(dotFiles.readLine().trimmed()).split(';', QString::SkipEmptyParts);
+ if (outfile.exists()) {
+ // set generateAll = true if MOC_COMPILE_DEFINITIONS changed
+ outfile.open(QIODevice::ReadOnly | QIODevice::Text);
+ const QByteArray &buf = outfile.readLine();
+ if (buf.endsWith("*/")) {
+ // it's an old file, which doesn't contain mocDefinitions info
+ generateAll = true;
+ } else {
+ QByteArray buf = outfile.readLine();
+ buf.chop(1); // remove trailing \n
+ lazyInitMocDefinitions();
+ generateAll = (buf != mocDefinitions.join(QString(QLatin1Char(' '))).toUtf8());
+ }
+ outfile.close();
+ } else {
+ generateAll = true;
+ }
+
// the program goes through all .cpp files to see which moc files are included. It is not really
// interesting how the moc file is named, but what file the moc is created from. Once a moc is
// included the same moc may not be included in the _automoc.cpp file anymore. OTOH if there's a
@@ -449,7 +476,8 @@
QByteArray automocSource;
QTextStream outStream(&automocSource, QIODevice::WriteOnly);
- outStream << "/* This file is autogenerated, do not edit */\n";
+ outStream << "/* This file is autogenerated, do not edit\n"
+ << mocDefinitions.join(QString(QLatin1Char(' '))) << "\n*/\n";
if (notIncludedMocs.isEmpty()) {
outStream << "enum some_compilers { need_more_than_nothing };\n";
_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem