diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-06-01 15:08:39 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-06-01 19:34:28 (GMT) |
commit | f1249f94c07654f0b76e7a90fb81ed5b58cd30f7 (patch) | |
tree | f8a18a3bbc7b4b0c3bf6f11b3cb2aa39e018adbe /tools/linguist/lrelease | |
parent | 9f71cffea1d5cdac94ae7368ffa7f54183ac33a4 (diff) | |
download | Qt-f1249f94c07654f0b76e7a90fb81ed5b58cd30f7.zip Qt-f1249f94c07654f0b76e7a90fb81ed5b58cd30f7.tar.gz Qt-f1249f94c07654f0b76e7a90fb81ed5b58cd30f7.tar.bz2 |
synchronize qmake project parser with qt creator
qt creator as of ddb918f.
not feeling like replaying the whole history ...
Diffstat (limited to 'tools/linguist/lrelease')
-rw-r--r-- | tools/linguist/lrelease/main.cpp | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index 96b1926..f9e08a0 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -40,7 +40,9 @@ ****************************************************************************/ #include "translator.h" -#include "profileevaluator.h" + +#include <profileparser.h> +#include <profileevaluator.h> #ifndef QT_BOOTSTRAPPED #include <QtCore/QCoreApplication> @@ -58,6 +60,8 @@ QT_USE_NAMESPACE #ifdef QT_BOOTSTRAPPED +static QString binDir; + static void initBinaryDir( #ifndef Q_OS_WIN const char *argv0 @@ -185,6 +189,40 @@ static bool releaseTsFile(const QString& tsFileName, return releaseTranslator(tor, qmFileName, cd, removeIdentical); } +static void print(const QString &fileName, int lineNo, const QString &msg) +{ + if (lineNo) + printErr(QString::fromLatin1("%2(%1): %3").arg(lineNo).arg(fileName, msg)); + else + printErr(msg); +} + +class ParseHandler : public ProFileParserHandler { +public: + virtual void parseError(const QString &fileName, int lineNo, const QString &msg) + { if (verbose) print(fileName, lineNo, msg); } + + bool verbose; +}; + +class EvalHandler : public ProFileEvaluatorHandler { +public: + virtual void configError(const QString &msg) + { printErr(msg); } + virtual void evalError(const QString &fileName, int lineNo, const QString &msg) + { if (verbose) print(fileName, lineNo, msg); } + virtual void fileMessage(const QString &msg) + { printErr(msg); } + + virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {} + virtual void doneWithEval(ProFile *) {} + + bool verbose; +}; + +static ParseHandler parseHandler; +static EvalHandler evalHandler; + int main(int argc, char **argv) { #ifdef QT_BOOTSTRAPPED @@ -272,23 +310,32 @@ int main(int argc, char **argv) if (inputFile.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive) || inputFile.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) { QFileInfo fi(inputFile); - ProFile pro(fi.absoluteFilePath()); - ProFileEvaluator visitor; - visitor.setVerbose(cd.isVerbose()); + parseHandler.verbose = evalHandler.verbose = cd.isVerbose(); + ProFileOption option; +#ifdef QT_BOOTSTRAPPED + option.initProperties(binDir + QLatin1String("/qmake")); +#else + option.initProperties(app.applicationDirPath() + QLatin1String("/qmake")); +#endif + ProFileParser parser(0, &parseHandler); + ProFileEvaluator visitor(&option, &parser, &evalHandler); - if (!visitor.queryProFile(&pro)) { + ProFile *pro; + if (!(pro = parser.parsedProFile(QDir::cleanPath(fi.absoluteFilePath())))) { printErr(LR::tr( "lrelease error: cannot read project file '%1'.\n") .arg(inputFile)); continue; } - if (!visitor.accept(&pro)) { + if (!visitor.accept(pro)) { printErr(LR::tr( "lrelease error: cannot process project file '%1'.\n") .arg(inputFile)); + pro->deref(); continue; } + pro->deref(); QStringList translations = visitor.values(QLatin1String("TRANSLATIONS")); if (translations.isEmpty()) { @@ -324,8 +371,6 @@ int main(int argc, char **argv) # include <windows.h> #endif -static QString binDir; - static void initBinaryDir( #ifndef Q_OS_WIN const char *_argv0 |