summaryrefslogtreecommitdiffstats
path: root/tools/linguist/shared/proreader.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-07-13 14:20:44 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-07-13 14:51:21 (GMT)
commite2f381365bf2158095c5c7236fc4b2f842b9fa8c (patch)
tree5bf317515ed903054c1f2df5bfb41b2356f76273 /tools/linguist/shared/proreader.cpp
parent45efa082135cbf97820a5ce7025685d22bd926ce (diff)
downloadQt-e2f381365bf2158095c5c7236fc4b2f842b9fa8c.zip
Qt-e2f381365bf2158095c5c7236fc4b2f842b9fa8c.tar.gz
Qt-e2f381365bf2158095c5c7236fc4b2f842b9fa8c.tar.bz2
implement proper vpath handling
this also removes the bogus special casing of various filename-containing variables inside the pro parser. while this is a feature as such, it restores backwards compatibility without damaging the correct behavior again, so it qualifies for 4.5. based on a2f40fce2a1cf3c19a13fa27eea08192493ab76e from creator Task-number: 254098
Diffstat (limited to 'tools/linguist/shared/proreader.cpp')
-rw-r--r--tools/linguist/shared/proreader.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/tools/linguist/shared/proreader.cpp b/tools/linguist/shared/proreader.cpp
index 492c2ef..3400f20 100644
--- a/tools/linguist/shared/proreader.cpp
+++ b/tools/linguist/shared/proreader.cpp
@@ -41,21 +41,49 @@
#include "profileevaluator.h"
+#include <QtCore/QDir>
#include <QtCore/QFileInfo>
QT_BEGIN_NAMESPACE
-void evaluateProFile(const ProFileEvaluator &visitor, QHash<QByteArray, QStringList> *varMap)
+static QStringList getSources(const char *var, const char *vvar, const QStringList &baseVPaths,
+ const QString &projectDir, const ProFileEvaluator &visitor)
{
+ QStringList vPaths =
+ visitor.absolutePathValues(QLatin1String(vvar), projectDir);
+ vPaths += baseVPaths;
+ vPaths.removeDuplicates();
+ return visitor.absoluteFileValues(QLatin1String(var), projectDir, vPaths, 0);
+}
+
+void evaluateProFile(const ProFileEvaluator &visitor, QHash<QByteArray, QStringList> *varMap,
+ const QString &projectDir)
+{
+ QStringList baseVPaths;
+ baseVPaths += visitor.absolutePathValues(QLatin1String("VPATH"), projectDir);
+ baseVPaths << projectDir; // QMAKE_ABSOLUTE_SOURCE_PATH
+ baseVPaths += visitor.absolutePathValues(QLatin1String("DEPENDPATH"), projectDir);
+ baseVPaths.removeDuplicates();
+
QStringList sourceFiles;
QString codecForTr;
QString codecForSource;
QStringList tsFileNames;
// app/lib template
- sourceFiles += visitor.values(QLatin1String("SOURCES"));
- sourceFiles += visitor.values(QLatin1String("HEADERS"));
- tsFileNames = visitor.values(QLatin1String("TRANSLATIONS"));
+ sourceFiles += getSources("SOURCES", "VPATH_SOURCES", baseVPaths, projectDir, visitor);
+
+ sourceFiles += getSources("FORMS", "VPATH_FORMS", baseVPaths, projectDir, visitor);
+ sourceFiles += getSources("FORMS3", "VPATH_FORMS3", baseVPaths, projectDir, visitor);
+
+ QStringList vPathsInc = baseVPaths;
+ vPathsInc += visitor.absolutePathValues(QLatin1String("INCLUDEPATH"), projectDir);
+ vPathsInc.removeDuplicates();
+ sourceFiles += visitor.absoluteFileValues(QLatin1String("HEADERS"), projectDir, vPathsInc, 0);
+
+ QDir proDir(projectDir);
+ foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS")))
+ tsFileNames << QFileInfo(proDir, tsFile).filePath();
QStringList trcodec = visitor.values(QLatin1String("CODEC"))
+ visitor.values(QLatin1String("DEFAULTCODEC"))
@@ -67,11 +95,6 @@ void evaluateProFile(const ProFileEvaluator &visitor, QHash<QByteArray, QStringL
if (!srccodec.isEmpty())
codecForSource = srccodec.last();
- QStringList forms = visitor.values(QLatin1String("INTERFACES"))
- + visitor.values(QLatin1String("FORMS"))
- + visitor.values(QLatin1String("FORMS3"));
- sourceFiles << forms;
-
sourceFiles.sort();
sourceFiles.removeDuplicates();
tsFileNames.sort();
@@ -100,7 +123,7 @@ bool evaluateProFile(const QString &fileName, bool verbose, QHash<QByteArray, QS
if (!visitor.accept(&pro))
return false;
- evaluateProFile(visitor, varMap);
+ evaluateProFile(visitor, varMap, fi.absolutePath());
return true;
}