On Thursday 20 November 2008 10:27:11 Matthias Kretz wrote:
> Now, for some reason qt4_generate_moc stopped working for me. I don't see
> how that could be related, if it is and you have an idea please take a
> look.

It seems I found the problem:
the OBJECT_DEPENDS I added in Automoc4Config overwrites the OBJECT_DEPENDS 
from qt4_generate_moc. I changed automoc to also use macro_add_file_dependency 
now and kdelibs compiles again.

New atuomoc patch attached. I'd like to commit this, please review.

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/

Index: kde4automoc.cpp
===================================================================
--- kde4automoc.cpp	(revision 886850)
+++ kde4automoc.cpp	(working copy)
@@ -60,7 +60,6 @@
         void dotFilesCheck(bool);
         void lazyInitMocDefinitions();
         void lazyInit();
-        bool touch(const QString &filename);
         bool generateMoc(const QString &sourceFile, const QString &mocFileName);
         void printUsage(const QString &);
         void printVersion();
@@ -87,12 +86,12 @@
         bool failed;
         bool automocCppChanged;
         bool generateAll;
-        bool doTouch;
 };
 
 void AutoMoc::printUsage(const QString &path)
 {
-    cout << "Usage: " << path << " <outfile> <srcdir> <builddir> <moc executable> <cmake executable> [--touch]" << endl;
+    cout << "Usage: " << path << " <outfile> <srcdir> <builddir> <moc executable> <cmake executable>" << endl;
+    cout << "or:    " << path << " --touch <file containing filepaths to touch>" << endl;
 }
 
 void AutoMoc::printVersion()
@@ -119,7 +118,7 @@
 
 AutoMoc::AutoMoc()
     : verbose(!qgetenv("VERBOSE").isEmpty()), cerr(stderr), cout(stdout), failed(false),
-    automocCppChanged(false), generateAll(false), doTouch(false)
+    automocCppChanged(false), generateAll(false)
 {
     const QByteArray colorEnv = qgetenv("COLOR");
     cmakeEchoColorArgs << QLatin1String("-E") << QLatin1String("cmake_echo_color") 
@@ -163,12 +162,6 @@
     mocExe = args[4];
     cmakeExecutable = args[5];
 
-    if (args.size() > 6) {
-        if (args[6] == QLatin1String("--touch")) {
-            doTouch = true;
-        }
-    }
-
     lazyInitMocDefinitions();
 
     QByteArray line = dotFiles.readLine();
@@ -235,8 +228,28 @@
         printUsage(args[0]);
        ::exit(EXIT_FAILURE);
         }
-    }
-    else if (args.size() < 5) {
+    } else if (args.size() == 3) {
+        if (args[1] != "--touch") {
+            printUsage(args[0]);
+            ::exit(EXIT_FAILURE);
+        }
+        QFile filesFile(args[2]);
+        filesFile.open(QIODevice::ReadOnly | QIODevice::Text);
+        QByteArray line = filesFile.readLine().trimmed();
+        while (!line.isEmpty()) {
+#ifdef Q_OS_WIN
+            _wutime(reinterpret_cast<const wchar_t *>(QString::fromLocal8Bit(line).utf16()), 0);
+#else
+            int err = utime(line.constData(), NULL);
+            if (err == -1) {
+                err = errno;
+                cerr << strerror(err) << "\n";
+            }
+#endif
+            line = filesFile.readLine().trimmed();
+        }
+        ::exit(0);
+    } else if (args.size() != 6) {
         printUsage(args[0]);
        ::exit(EXIT_FAILURE);
     }
@@ -514,38 +527,11 @@
     outfile.write(automocSource);
     outfile.close();
 
-    // update the timestamp on the _automoc.cpp.files file to make sure we get called again
     dotFiles.close();
-    if (doTouch && !touch(dotFiles.fileName())) {
-        return false;
-    }
 
     return true;
 }
 
-bool AutoMoc::touch(const QString &_filename)
-{
-    // sleep for 1s in order to make the modification time greater than the modification time of
-    // the files written before. Equal modification time is not good enough. Just using utime with
-    // time(NULL) + 1 is also not a good solution as then make will complain about clock skew.
-#ifdef Q_OS_WIN
-    Sleep(1000);
-    _wutime(reinterpret_cast<const wchar_t *>(_filename.utf16()), 0);
-#else
-    const QByteArray &filename = QFile::encodeName(_filename);
-    const struct timespec sleepDuration = { 1, 0 };
-    nanosleep(&sleepDuration, NULL);
-
-    int err = utime(filename.constData(), NULL);
-    if (err == -1) {
-        err = errno;
-        cerr << strerror(err) << "\n";
-        return false;
-    }
-#endif
-    return true;
-}
-
 bool AutoMoc::generateMoc(const QString &sourceFile, const QString &mocFileName)
 {
     //qDebug() << Q_FUNC_INFO << sourceFile << mocFileName;
Index: Automoc4Config.cmake
===================================================================
--- Automoc4Config.cmake	(revision 886850)
+++ Automoc4Config.cmake	(working copy)
@@ -1,5 +1,5 @@
 
-
+include(MacroAddFileDependencies)
 get_filename_component(_AUTOMOC4_CURRENT_DIR  "${CMAKE_CURRENT_LIST_FILE}" PATH)
 
 # set the automoc version number
@@ -37,6 +37,18 @@
    endif(_headers_to_moc)
 endmacro (AUTOMOC4_MOC_HEADERS)
 
+set(AUTOMOC4_INIT_FILE "${CMAKE_BINARY_DIR}/automoc4_init.files")
+add_custom_target(automoc4_init
+   ${AUTOMOC4_EXECUTABLE}
+   --touch
+   ${AUTOMOC4_INIT_FILE}
+   COMMENT "initialize automoc4"
+   VERBATIM
+   )
+if(_AUTOMOC4_EXECUTABLE_DEP)
+   add_dependencies("automoc4_init" "automoc4")
+endif(_AUTOMOC4_EXECUTABLE_DEP)
+file(WRITE ${AUTOMOC4_INIT_FILE} "")
 
 macro(AUTOMOC4 _target_NAME _SRCS)
    set(_moc_files)
@@ -78,12 +90,15 @@
          ${CMAKE_CURRENT_BINARY_DIR}
          ${QT_MOC_EXECUTABLE}
          ${CMAKE_COMMAND}
-         --touch
          DEPENDS ${_automoc_source}.files ${_AUTOMOC4_EXECUTABLE_DEP}
          COMMENT ""
          VERBATIM
          )
+      foreach(_src ${${_SRCS}})
+         macro_add_file_dependencies(${_src} ${_automoc_source})
+      endforeach(_src)
       set(${_SRCS} ${_automoc_source} ${${_SRCS}})
+      file(APPEND ${AUTOMOC4_INIT_FILE} "${_automoc_source}.files\n")
    endif(_moc_files)
 endmacro(AUTOMOC4)
 
@@ -171,6 +186,8 @@
    add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS})
    if(MSVC)
       add_dependencies(${_target_NAME} "${_target_NAME}_automoc")
+   else(MSVC)
+      add_dependencies(${_target_NAME} "automoc4_init")
    endif(MSVC)
 endmacro(AUTOMOC4_ADD_EXECUTABLE)
 
@@ -194,5 +211,7 @@
    add_library(${_target_NAME} ${_add_executable_param} ${_SRCS})
    if(MSVC)
       add_dependencies(${_target_NAME} "${_target_NAME}_automoc")
+   else(MSVC)
+      add_dependencies(${_target_NAME} "automoc4_init")
    endif(MSVC)
 endmacro(AUTOMOC4_ADD_LIBRARY)
Index: Automoc4Version.cmake
===================================================================
--- Automoc4Version.cmake	(revision 886850)
+++ Automoc4Version.cmake	(working copy)
@@ -1,7 +1,7 @@
 # set the current version number
 set(AUTOMOC4_VERSION_MAJOR  "0")
 set(AUTOMOC4_VERSION_MINOR  "9")
-set(AUTOMOC4_VERSION_PATCH "87")
+set(AUTOMOC4_VERSION_PATCH "88")
 
 set(AUTOMOC4_VERSION "${AUTOMOC4_VERSION_MAJOR}.${AUTOMOC4_VERSION_MINOR}.${AUTOMOC4_VERSION_PATCH}")
 
_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to