diff options
Diffstat (limited to 'tools/linguist')
-rw-r--r-- | tools/linguist/lrelease/lrelease.pro | 11 | ||||
-rw-r--r-- | tools/linguist/lrelease/main.cpp | 96 | ||||
-rw-r--r-- | tools/linguist/shared/proparserutils.h | 25 | ||||
-rw-r--r-- | tools/linguist/shared/qm.cpp | 2 | ||||
-rw-r--r-- | tools/linguist/shared/translator.cpp | 10 | ||||
-rw-r--r-- | tools/linguist/shared/translator.h | 12 |
6 files changed, 145 insertions, 11 deletions
diff --git a/tools/linguist/lrelease/lrelease.pro b/tools/linguist/lrelease/lrelease.pro index 01091b3..28a741d 100644 --- a/tools/linguist/lrelease/lrelease.pro +++ b/tools/linguist/lrelease/lrelease.pro @@ -2,19 +2,10 @@ TEMPLATE = app TARGET = lrelease DESTDIR = ../../../bin -QT -= gui - -CONFIG += qt warn_on console -CONFIG -= app_bundle - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII SOURCES += main.cpp +include(../../../src/tools/bootstrap/bootstrap.pri) include(../shared/formats.pri) include(../shared/proparser.pri) diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index c88c909..c45459a 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -42,7 +42,10 @@ #include "translator.h" #include "proreader.h" +#ifndef QT_BOOTSTRAPPED #include <QtCore/QCoreApplication> +#include <QtCore/QTranslator> +#endif #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFile> @@ -51,7 +54,14 @@ #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QTextStream> -#include <QtCore/QTranslator> + +#ifdef QT_BOOTSTRAPPED +static void initBinaryDir( +#ifndef Q_OS_WIN + const char *argv0 +#endif + ); +#endif static void printOut(const QString & out) { @@ -157,10 +167,18 @@ static bool releaseTsFile(const QString& tsFileName, int main(int argc, char **argv) { +#ifdef QT_BOOTSTRAPPED + initBinaryDir( +#ifndef Q_OS_WIN + argv[0] +#endif + ); +#else QCoreApplication app(argc, argv); QTranslator translator; if (translator.load(QLatin1String("lrelease_") + QLocale::system().name())) app.installTranslator(&translator); +#endif ConversionData cd; cd.m_verbose = true; // the default is true starting with Qt 4.2 @@ -260,3 +278,79 @@ int main(int argc, char **argv) return 0; } + +#ifdef QT_BOOTSTRAPPED + +#ifdef Q_OS_WIN +# include <windows.h> +#endif + +static QString binDir; + +static void initBinaryDir( +#ifndef Q_OS_WIN + const char *_argv0 +#endif + ) +{ +#ifdef Q_OS_WIN + wchar_t module_name[MAX_PATH]; + GetModuleFileName(0, module_name, MAX_PATH); + QFileInfo filePath = QString::fromWCharArray(module_name); + binDir = filePath.filePath(); +#else + QString argv0 = QFile::decodeName(QByteArray(_argv0)); + QString absPath; + + if (!argv0.isEmpty() && argv0.at(0) == QLatin1Char('/')) { + /* + If argv0 starts with a slash, it is already an absolute + file path. + */ + absPath = argv0; + } else if (argv0.contains(QLatin1Char('/'))) { + /* + If argv0 contains one or more slashes, it is a file path + relative to the current directory. + */ + absPath = QDir::current().absoluteFilePath(argv0); + } else { + /* + Otherwise, the file path has to be determined using the + PATH environment variable. + */ + QByteArray pEnv = qgetenv("PATH"); + QDir currentDir = QDir::current(); + QStringList paths = QString::fromLocal8Bit(pEnv.constData()).split(QLatin1String(":")); + for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { + if ((*p).isEmpty()) + continue; + QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0); + QFileInfo candidate_fi(candidate); + if (candidate_fi.exists() && !candidate_fi.isDir()) { + binDir = candidate_fi.canonicalPath(); + return; + } + } + return; + } + + QFileInfo fi(absPath); + if (fi.exists()) + binDir = fi.canonicalPath(); +#endif +} + +QT_BEGIN_NAMESPACE + +// The name is hard-coded in QLibraryInfo +QString qmake_libraryInfoFile() +{ + if (binDir.isEmpty()) + return QString(); + return QDir(binDir).filePath(QString::fromLatin1("qt.conf")); +} + +QT_END_NAMESPACE + +#endif // QT_BOOTSTRAPPED diff --git a/tools/linguist/shared/proparserutils.h b/tools/linguist/shared/proparserutils.h index 9a83733..1ed3d6c 100644 --- a/tools/linguist/shared/proparserutils.h +++ b/tools/linguist/shared/proparserutils.h @@ -43,10 +43,35 @@ #define PROPARSERUTILS_H #include <QtCore/QDir> +#ifndef QT_BOOTSTRAPPED #include <QtCore/QLibraryInfo> +#endif QT_BEGIN_NAMESPACE +#ifdef QT_BOOTSTRAPPED +// this is a stripped down version of the one found in QtCore +class QLibraryInfo +{ +public: + enum LibraryLocation + { + PrefixPath, + DocumentationPath, + HeadersPath, + LibrariesPath, + BinariesPath, + PluginsPath, + DataPath, + TranslationsPath, + SettingsPath, + DemosPath, + ExamplesPath + }; + static QString location(LibraryLocation); +}; +#endif + // Pre- and postcondition macros #define PRE(cond) do {if (!(cond))qt_assert(#cond,__FILE__,__LINE__);} while (0) #define POST(cond) do {if (!(cond))qt_assert(#cond,__FILE__,__LINE__);} while (0) diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 99aedef..e4c26bc 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -41,7 +41,9 @@ #include "translator.h" +#ifndef QT_BOOTSTRAPPED #include <QtCore/QCoreApplication> +#endif #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFile> diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index bc27daf..05fc6e5 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -56,6 +56,16 @@ QT_BEGIN_NAMESPACE +#ifdef QT_BOOTSTRAPPED +QString QObject::tr(const char *sourceText, const char *, int n) +{ + QString ret = QString::fromLatin1(sourceText); + if (n >= 0) + ret.replace(QLatin1String("%n"), QString::number(n)); + return ret; +} +#endif + Translator::Translator() : m_codecName("ISO-8859-1"), m_locationsType(AbsoluteLocations) diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index eec704a..f29317b 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -54,6 +54,18 @@ QT_BEGIN_NAMESPACE +#ifdef QT_BOOTSTRAPPED +struct QObject { + static QString tr(const char *sourceText, const char * = 0, int n = -1); +}; +struct QCoreApplication : public QObject { + enum Encoding { CodecForTr }; + static QString translate(const char *, const char *sourceText, const char * = 0, + Encoding = CodecForTr, int n = -1) + { return tr(sourceText, 0, n); } +}; +#endif + class QIODevice; // A struct of "interesting" data passed to and from the load and save routines |