diff options
Diffstat (limited to 'src/qdoc/config.cpp')
-rw-r--r-- | src/qdoc/config.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp index 64c8786f6..27018007b 100644 --- a/src/qdoc/config.cpp +++ b/src/qdoc/config.cpp @@ -39,6 +39,9 @@ #include "config.h" #include "generator.h" #include <stdlib.h> +#if QT_CONFIG(process) +#include "qprocess.h" +#endif QT_BEGIN_NAMESPACE @@ -929,6 +932,30 @@ QStringList Config::loadMaster(const QString& fileName) } /*! + Returns the value of the environment variable \a varName. + If qgetenv() returns null and \a varName starts with 'Q', + try to query the variable from qmake. +*/ +QByteArray Config::getEnv(const char *varName) +{ + QByteArray var = qgetenv(varName); +#if QT_CONFIG(process) + if (var.isNull() && varName[0] == 'Q') { + QString path(QCoreApplication::applicationFilePath()); + path.replace(path.lastIndexOf('/') + 1, prog.size(), "qmake"); + QProcess qmake; + qmake.start(path, QStringList() << "-query" << varName); + if (qmake.waitForFinished()) { + QByteArray result = qmake.readAll().trimmed(); + if (result.at(0) != '*') + var = result; + } + } +#endif + return var; +} + +/*! Load, parse, and process a qdoc configuration file. This function is only called by the other load() function, but this one is recursive, i.e., it calls itself when it sees @@ -1032,7 +1059,7 @@ void Config::load(Location location, const QString& fileName) SKIP_CHAR(); } if (!var.isEmpty()) { - const QByteArray val = qgetenv(var.toLatin1().data()); + const QByteArray val = getEnv(var.toLatin1().data()); if (val.isNull()) { location.fatal(tr("Environment variable '%1' undefined").arg(var)); } @@ -1140,7 +1167,7 @@ void Config::load(Location location, const QString& fileName) SKIP_CHAR(); } if (!var.isEmpty()) { - const QByteArray val = qgetenv(var.toLatin1().constData()); + const QByteArray val = getEnv(var.toLatin1().constData()); if (val.isNull()) { location.fatal(tr("Environment variable '%1' undefined").arg(var)); } |