Search the include paths for json files containing plugin info
authorLars Knoll <lars.knoll@nokia.com>
Fri, 20 Jul 2012 10:39:53 +0000 (12:39 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 31 Jul 2012 09:13:43 +0000 (11:13 +0200)
This fixes shadow builds with autogenerated .json files as
e.g. used by Qt Creator.

Change-Id: Ibb783b05d97d996100da4b0dca859fa3f310dc83
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/tools/moc/main.cpp
src/tools/moc/moc.cpp
src/tools/moc/parser.h
src/tools/moc/preprocessor.h

index 905eed1..97b7075 100644 (file)
@@ -394,6 +394,7 @@ int runMoc(int _argc, char **_argv)
     }
 
     moc.currentFilenames.push(filename);
+    moc.includes = pp.includes;
 
     // 1. preprocess
     moc.symbols = pp.preprocessed(moc.filename, in);
index e76f2c1..f63404c 100644 (file)
@@ -1103,6 +1103,18 @@ void Moc::parsePluginData(ClassDef *def)
             next(STRING_LITERAL);
             QByteArray metaDataFile = unquotedLexem();
             QFileInfo fi(QFileInfo(QString::fromLocal8Bit(currentFilenames.top().constData())).dir(), QString::fromLocal8Bit(metaDataFile.constData()));
+            for (int j = 0; j < includes.size() && !fi.exists(); ++j) {
+                const IncludePath &p = includes.at(j);
+                if (p.isFrameworkPath)
+                    continue;
+
+                fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(metaDataFile.constData()));
+                // try again, maybe there's a file later in the include paths with the same name
+                if (fi.isDir()) {
+                    fi = QFileInfo();
+                    continue;
+                }
+            }
             if (!fi.exists()) {
                 QByteArray msg;
                 msg += "Plugin Metadata file ";
index 1d69e64..654168f 100644 (file)
@@ -56,6 +56,15 @@ public:
     bool displayWarnings;
     bool displayNotes;
 
+    struct IncludePath
+    {
+        inline explicit IncludePath(const QByteArray &_path)
+            : path(_path), isFrameworkPath(false) {}
+        QByteArray path;
+        bool isFrameworkPath;
+    };
+    QList<IncludePath> includes;
+
     QStack<QByteArray> currentFilenames;
 
     inline bool hasNext() const { return (index < symbols.size()); }
index 4e0bd63..e5bc7d4 100644 (file)
@@ -69,14 +69,6 @@ class Preprocessor : public Parser
 public:
     Preprocessor(){}
     static bool preprocessOnly;
-    struct IncludePath
-    {
-        inline explicit IncludePath(const QByteArray &_path)
-            : path(_path), isFrameworkPath(false) {}
-        QByteArray path;
-        bool isFrameworkPath;
-    };
-    QList<IncludePath> includes;
     QList<QByteArray> frameworks;
     QSet<QByteArray> preprocessedIncludes;
     Macros macros;