summaryrefslogtreecommitdiffstats
path: root/tools/linguist/lupdate
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-26 18:19:33 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-27 15:12:31 (GMT)
commitb0a454fd09e0cbf74304aabd160ea25c2c83b4b9 (patch)
tree1769a83d39bd8309cd552ab733804443e7cbbd95 /tools/linguist/lupdate
parent03e114b11ee5cd51e0b9151e0c728fe370578d53 (diff)
downloadQt-b0a454fd09e0cbf74304aabd160ea25c2c83b4b9.zip
Qt-b0a454fd09e0cbf74304aabd160ea25c2c83b4b9.tar.gz
Qt-b0a454fd09e0cbf74304aabd160ea25c2c83b4b9.tar.bz2
unshare pro post-processing code
lrelease needs only the TRANSLATIONS value anyway, so there is hardly anything to share for real
Diffstat (limited to 'tools/linguist/lupdate')
-rw-r--r--tools/linguist/lupdate/main.cpp60
1 files changed, 48 insertions, 12 deletions
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index c5051cd..44717bf 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -43,7 +43,6 @@
#include <translator.h>
#include <profileevaluator.h>
-#include <proreader.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
@@ -214,6 +213,42 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
}
}
+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);
+}
+
+static QStringList getSources(const ProFileEvaluator &visitor, 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;
+
+ // app/lib template
+ 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);
+
+ sourceFiles.removeDuplicates();
+ sourceFiles.sort();
+
+ return sourceFiles;
+}
+
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@@ -467,7 +502,6 @@ int main(int argc, char **argv)
QStringList tsFiles = tsFileNames;
if (proFiles.count() > 0) {
QFileInfo pfi(proFiles.takeFirst());
- QHash<QByteArray, QStringList> variables;
ProFileEvaluator visitor;
visitor.setVerbose(options & Verbose);
@@ -494,19 +528,19 @@ int main(int argc, char **argv)
cd.m_includePath += visitor.values(QLatin1String("INCLUDEPATH"));
- evaluateProFile(visitor, &variables, pfi.absolutePath());
-
- sourceFiles = variables.value("SOURCES");
+ sourceFiles = getSources(visitor, pfi.absolutePath());
- QStringList tmp = variables.value("CODECFORTR");
- if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
- codecForTr = tmp.first().toLatin1();
+ QStringList tmp = visitor.values(QLatin1String("CODEC"))
+ + visitor.values(QLatin1String("DEFAULTCODEC"))
+ + visitor.values(QLatin1String("CODECFORTR"));
+ if (!tmp.isEmpty()) {
+ codecForTr = tmp.last().toLatin1();
fetchedTor.setCodecName(codecForTr);
cd.m_outputCodec = codecForTr;
}
- tmp = variables.value("CODECFORSRC");
- if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
- codecForSource = tmp.first().toLatin1();
+ tmp = visitor.values(QLatin1String("CODECFORSRC"));
+ if (!tmp.isEmpty()) {
+ codecForSource = tmp.last().toLatin1();
if (!QTextCodec::codecForName(codecForSource))
qWarning("lupdate warning: Codec for source '%s' is invalid. Falling back to codec for tr().",
codecForSource.constData());
@@ -514,7 +548,9 @@ int main(int argc, char **argv)
cd.m_codecForSource = codecForSource;
}
- tsFiles += variables.value("TRANSLATIONS");
+ QDir proDir(pfi.absolutePath());
+ foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS")))
+ tsFiles << QFileInfo(proDir, tsFile).filePath();
}
QStringList sourceFilesCpp;