Commit 3cb595fa authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

add ProFileOption::initProperties()

centralize support for default-initialization of qmake properties with,
duh, qmake (-query).

Change-Id: If97725fa61779819f6afb9073042b667d7253e5d
Reviewed-on: http://codereview.qt.nokia.com/308

Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 9e7ad28c
......@@ -172,6 +172,39 @@ QString ProFileOption::getEnv(const QString &var) const
return QString::fromLocal8Bit(qgetenv(var.toLocal8Bit().constData()));
}
#ifdef PROEVALUATOR_INIT_PROPS
bool ProFileOption::initProperties(const QString &qmake)
{
QByteArray data;
#ifndef QT_BOOTSTRAPPED
QProcess proc;
proc.start(qmake, QStringList() << QLatin1String("-query"));
if (!proc.waitForFinished())
return false;
data = proc.readAll();
#else
if (FILE *proc = QT_POPEN(QString(IoUtils::shellQuote(qmake) + QLatin1String(" -query"))
.toLocal8Bit(), "r")) {
char buff[1024];
while (!feof(proc))
data.append(buff, int(fread(buff, 1, 1023, proc)));
QT_PCLOSE(proc);
}
#endif
foreach (QByteArray line, data.split('\n'))
if (!line.startsWith("QMAKE_")) {
int off = line.indexOf(':');
if (off < 0) // huh?
continue;
if (line.endsWith('\r'))
line.chop(1);
properties.insert(QString::fromLatin1(line.left(off)),
QString::fromLocal8Bit(line.mid(off + 1)));
}
return true;
}
#endif
///////////////////////////////////////////////////////////////////////
//
// ProFileEvaluator::Private
......
......@@ -186,6 +186,9 @@ struct PROPARSER_EXPORT ProFileOption
// -nocache, -cache, -spec, QMAKESPEC
// -set persistent value
void setCommandLineArguments(const QStringList &args);
#ifdef PROEVALUATOR_INIT_PROPS
bool initProperties(const QString &qmake);
#endif
private:
friend class ProFileEvaluator;
......
......@@ -160,33 +160,11 @@ int main(int argc, char **argv)
qFatal("need at least two arguments: [-v] <cumulative?> <filenme> [<out_pwd> [<qmake options>]]");
ProFileOption option;
option.initProperties(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmake"));
if (args.count() >= 4)
option.setCommandLineArguments(args.mid(3));
ProFileParser parser(0, &parseHandler);
static const struct {
const char * const name;
QLibraryInfo::LibraryLocation index;
} props[] = {
{ "QT_INSTALL_DATA", QLibraryInfo::DataPath },
{ "QT_INSTALL_LIBS", QLibraryInfo::LibrariesPath },
{ "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath },
{ "QT_INSTALL_HEADERS", QLibraryInfo::HeadersPath },
{ "QT_INSTALL_DEMOS", QLibraryInfo::DemosPath },
{ "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath },
{ "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath },
{ "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath },
{ "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath },
{ "QT_INSTALL_BINS", QLibraryInfo::BinariesPath },
{ "QT_INSTALL_DOCS", QLibraryInfo::DocumentationPath },
{ "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath }
};
for (unsigned i = 0; i < sizeof(props)/sizeof(props[0]); ++i)
option.properties.insert(QLatin1String(props[i].name),
QLibraryInfo::location(props[i].index));
option.properties.insert(QLatin1String("QT_VERSION"), QLatin1String(qVersion()));
bool cumulative = args[0] == QLatin1String("true");
QFileInfo infi(args[1]);
QString file = infi.absoluteFilePath();
......
......@@ -20,4 +20,4 @@ HEADERS = profileparser.h profileevaluator.h proitems.h ioutils.h
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION
DEFINES += PROEVALUATOR_CUMULATIVE
DEFINES += PROEVALUATOR_CUMULATIVE PROEVALUATOR_INIT_PROPS
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment