On Thursday 17 April 2008, Matthias Kretz wrote: > run kde4automoc unconditionally for all targets
With a patch to kde4automoc.cpp it's not too bad. Please try the attached patch. And if you think this is the way to go then let me know how to unconditionally run automoc without that touch hack. -- ________________________________________________________ Matthias Kretz (Germany) <>< http://Vir.homelinux.org/ [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
Index: automoc/kde4automoc.cpp =================================================================== --- automoc/kde4automoc.cpp (revision 797272) +++ automoc/kde4automoc.cpp (working copy) @@ -38,7 +38,7 @@ bool run(); private: - void generateMoc(const QString &sourceFile, const QString &mocFileName); + bool generateMoc(const QString &sourceFile, const QString &mocFileName); void waitForProcesses(); void usage(const QString &); void echoColor(const QString &msg) @@ -66,6 +66,7 @@ }; QQueue<Process> processes; bool failed; + bool automocCppChanged; }; void AutoMoc::usage(const QString &path) @@ -84,7 +85,8 @@ } AutoMoc::AutoMoc() - : verbose(!qgetenv("VERBOSE").isEmpty()), cerr(stderr), cout(stdout), failed(false) + : verbose(!qgetenv("VERBOSE").isEmpty()), cerr(stderr), cout(stdout), failed(false), + automocCppChanged(false) { const QByteArray colorEnv = qgetenv("COLOR"); cmakeEchoColorArgs << "-E" << "cmake_echo_color" << QString("--switch=") + colorEnv << "--blue" @@ -256,7 +258,9 @@ end = notIncludedMocs.constEnd(); it = notIncludedMocs.constBegin(); for (; it != end; ++it) { - generateMoc(it.key(), it.value()); + if (generateMoc(it.key(), it.value())) { + automocCppChanged = true; + } outStream << "#include \"" << it.value() << "\"\n"; } } @@ -272,7 +276,19 @@ } outStream.flush(); - // source file that includes all remaining moc files + if (!automocCppChanged) { + // compare contents of the _automoc.cpp file + outfile.open(QIODevice::ReadOnly | QIODevice::Text); + const QByteArray oldContents = outfile.readAll(); + outfile.close(); + if (oldContents == automocSource) { + // nothing changed: don't touch the _automoc.cpp file + return true; + } + } + // either the contents of the _automoc.cpp file or one of the mocs included by it have changed + + // source file that includes all remaining moc files (_automoc.cpp file) outfile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); outfile.write(automocSource); outfile.close(); @@ -301,7 +317,7 @@ } } -void AutoMoc::generateMoc(const QString &sourceFile, const QString &mocFileName) +bool AutoMoc::generateMoc(const QString &sourceFile, const QString &mocFileName) { //qDebug() << Q_FUNC_INFO << sourceFile << mocFileName; const QString mocFilePath = builddir + mocFileName; @@ -332,13 +348,15 @@ args << "-o" << mocFilePath << sourceFile; //qDebug() << "executing: " << mocExe << args; mocProc->start(mocExe, args, QIODevice::NotOpen); - if (mocProc->waitForStarted()) + if (mocProc->waitForStarted()) { processes.enqueue(Process(mocProc, mocFilePath)); - else { + return true; + } else { cerr << "kde4automoc: process for " << mocFilePath << "failed to start: " << mocProc->errorString() << endl; failed = true; delete mocProc; } } + return false; } Index: modules/KDE4Macros.cmake =================================================================== --- modules/KDE4Macros.cmake (revision 797272) +++ modules/KDE4Macros.cmake (working copy) @@ -226,7 +226,10 @@ ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_MOC_EXECUTABLE} + COMMAND touch ${_automoc_source}.files DEPENDS ${${_SRCS}} ${_moc_headers} ${_automoc_source}.files ${_KDE4_AUTOMOC_EXECUTABLE_DEP} + COMMENT "running automoc for ${_target_NAME}" + VERBATIM ) # the OBJECT_DEPENDS is only necessary when a new moc file has to be generated that is included in a source file # problem: the whole target is recompiled when the automoc.cpp file is touched
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Kde-buildsystem mailing list Kde-buildsystem@kde.org https://mail.kde.org/mailman/listinfo/kde-buildsystem