From c0e9041b6dc2cc46334df2dffe640f1ead1e0898 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 29 Feb 2012 14:02:48 +0100 Subject: optimize QMakeProperty make it table-driven and have it cache the immutable values from QLibraryInfo. Change-Id: I07ed89152aa964bc9edf4436ee7c42f99cc6bcd3 Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- qmake/property.cpp | 66 ++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 39 deletions(-) (limited to 'qmake/property.cpp') diff --git a/qmake/property.cpp b/qmake/property.cpp index 4221605545..dec204cb9c 100644 --- a/qmake/property.cpp +++ b/qmake/property.cpp @@ -51,8 +51,30 @@ QT_BEGIN_NAMESPACE QStringList qmake_mkspec_paths(); //project.cpp +static const struct { + const char *name; + QLibraryInfo::LibraryLocation loc; +} propList[] = { + { "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath }, + { "QT_INSTALL_DATA", QLibraryInfo::DataPath }, + { "QT_INSTALL_DOCS", QLibraryInfo::DocumentationPath }, + { "QT_INSTALL_HEADERS", QLibraryInfo::HeadersPath }, + { "QT_INSTALL_LIBS", QLibraryInfo::LibrariesPath }, + { "QT_INSTALL_BINS", QLibraryInfo::BinariesPath }, + { "QT_INSTALL_TESTS", QLibraryInfo::TestsPath }, + { "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath }, + { "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath }, + { "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath }, + { "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath }, + { "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath }, + { "QT_INSTALL_DEMOS", QLibraryInfo::ExamplesPath }, // Just backwards compat +}; + QMakeProperty::QMakeProperty() : settings(0) { + for (int i = 0; i < sizeof(propList)/sizeof(propList[0]); i++) + m_values[QString::fromLatin1(propList[i].name)] = + QLibraryInfo::location(propList[i].loc); } QMakeProperty::~QMakeProperty() @@ -80,32 +102,9 @@ QMakeProperty::keyBase(bool version) const QString QMakeProperty::value(QString v, bool just_check) { - if(v == "QT_INSTALL_PREFIX") - return QLibraryInfo::location(QLibraryInfo::PrefixPath); - else if(v == "QT_INSTALL_DATA") - return QLibraryInfo::location(QLibraryInfo::DataPath); - else if(v == "QT_INSTALL_DOCS") - return QLibraryInfo::location(QLibraryInfo::DocumentationPath); - else if(v == "QT_INSTALL_HEADERS") - return QLibraryInfo::location(QLibraryInfo::HeadersPath); - else if(v == "QT_INSTALL_LIBS") - return QLibraryInfo::location(QLibraryInfo::LibrariesPath); - else if(v == "QT_INSTALL_BINS") - return QLibraryInfo::location(QLibraryInfo::BinariesPath); - else if(v == "QT_INSTALL_TESTS") - return QLibraryInfo::location(QLibraryInfo::TestsPath); - else if(v == "QT_INSTALL_PLUGINS") - return QLibraryInfo::location(QLibraryInfo::PluginsPath); - else if(v == "QT_INSTALL_IMPORTS") - return QLibraryInfo::location(QLibraryInfo::ImportsPath); - else if(v == "QT_INSTALL_TRANSLATIONS") - return QLibraryInfo::location(QLibraryInfo::TranslationsPath); - else if(v == "QT_INSTALL_CONFIGURATION") - return QLibraryInfo::location(QLibraryInfo::SettingsPath); - else if(v == "QT_INSTALL_EXAMPLES") - return QLibraryInfo::location(QLibraryInfo::ExamplesPath); - else if(v == "QT_INSTALL_DEMOS") - return QLibraryInfo::location(QLibraryInfo::ExamplesPath); + QString val = m_values.value(v); + if (!val.isNull()) + return val; else if(v == "QMAKE_MKSPECS") return qmake_mkspec_paths().join(Option::dirlist_sep); else if(v == "QMAKE_VERSION") @@ -194,19 +193,8 @@ QMakeProperty::exec() } } QStringList specialProps; - specialProps.append("QT_INSTALL_PREFIX"); - specialProps.append("QT_INSTALL_DATA"); - specialProps.append("QT_INSTALL_DOCS"); - specialProps.append("QT_INSTALL_HEADERS"); - specialProps.append("QT_INSTALL_LIBS"); - specialProps.append("QT_INSTALL_BINS"); - specialProps.append("QT_INSTALL_TESTS"); - specialProps.append("QT_INSTALL_PLUGINS"); - specialProps.append("QT_INSTALL_IMPORTS"); - specialProps.append("QT_INSTALL_TRANSLATIONS"); - specialProps.append("QT_INSTALL_CONFIGURATION"); - specialProps.append("QT_INSTALL_EXAMPLES"); - specialProps.append("QT_INSTALL_DEMOS"); + for (int i = 0; i < sizeof(propList)/sizeof(propList[0]); i++) + specialProps.append(QString::fromLatin1(propList[i].name)); specialProps.append("QMAKE_MKSPECS"); specialProps.append("QMAKE_VERSION"); #ifdef QT_VERSION_STR -- cgit v1.2.3 From 012f799254eedc610e2e33842e62d2a184b14fcc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 20:57:38 +0100 Subject: revamp -sysroot and -hostprefix handling instead of being a variable added to the makespec (via qconfig.pri), QT_SYSROOT is now a property. the QT_INSTALL_... properties are now automatically prefixed with the sysroot; the raw values are available as QT_RAW_INSTALL_... - this is expected to cause the least migration effort for existing projects. -hostprefix and the new -hostbindir & -hostdatadir now feed the new QT_HOST_... properties. adapted the qmake feature files and the qtbase build system accordingly. Change-Id: Iaa9b65bc10d9fe9c4988d620c70a8ce72177f8d4 Reviewed-by: Marius Storm-Olsen --- qmake/property.cpp | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'qmake/property.cpp') diff --git a/qmake/property.cpp b/qmake/property.cpp index dec204cb9c..7cb689ed7e 100644 --- a/qmake/property.cpp +++ b/qmake/property.cpp @@ -54,27 +54,45 @@ QStringList qmake_mkspec_paths(); //project.cpp static const struct { const char *name; QLibraryInfo::LibraryLocation loc; + bool raw; } propList[] = { - { "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath }, - { "QT_INSTALL_DATA", QLibraryInfo::DataPath }, - { "QT_INSTALL_DOCS", QLibraryInfo::DocumentationPath }, - { "QT_INSTALL_HEADERS", QLibraryInfo::HeadersPath }, - { "QT_INSTALL_LIBS", QLibraryInfo::LibrariesPath }, - { "QT_INSTALL_BINS", QLibraryInfo::BinariesPath }, - { "QT_INSTALL_TESTS", QLibraryInfo::TestsPath }, - { "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath }, - { "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath }, - { "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath }, - { "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath }, - { "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath }, - { "QT_INSTALL_DEMOS", QLibraryInfo::ExamplesPath }, // Just backwards compat + { "QT_SYSROOT", QLibraryInfo::SysrootPath, true }, + { "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath, false }, + { "QT_INSTALL_DATA", QLibraryInfo::DataPath, false }, + { "QT_INSTALL_DOCS", QLibraryInfo::DocumentationPath, false }, + { "QT_INSTALL_HEADERS", QLibraryInfo::HeadersPath, false }, + { "QT_INSTALL_LIBS", QLibraryInfo::LibrariesPath, false }, + { "QT_INSTALL_BINS", QLibraryInfo::BinariesPath, false }, + { "QT_INSTALL_TESTS", QLibraryInfo::TestsPath, false }, + { "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath, false }, + { "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath, false }, + { "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath, false }, + { "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath, false }, + { "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath, false }, + { "QT_INSTALL_DEMOS", QLibraryInfo::ExamplesPath, false }, // Just backwards compat + { "QT_RAW_INSTALL_PREFIX", QLibraryInfo::PrefixPath, true }, + { "QT_RAW_INSTALL_DATA", QLibraryInfo::DataPath, true }, + { "QT_RAW_INSTALL_DOCS", QLibraryInfo::DocumentationPath, true }, + { "QT_RAW_INSTALL_HEADERS", QLibraryInfo::HeadersPath, true }, + { "QT_RAW_INSTALL_LIBS", QLibraryInfo::LibrariesPath, true }, + { "QT_RAW_INSTALL_BINS", QLibraryInfo::BinariesPath, true }, + { "QT_RAW_INSTALL_TESTS", QLibraryInfo::TestsPath, true }, + { "QT_RAW_INSTALL_PLUGINS", QLibraryInfo::PluginsPath, true }, + { "QT_RAW_INSTALL_IMPORTS", QLibraryInfo::ImportsPath, true }, + { "QT_RAW_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath, true }, + { "QT_RAW_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath, true }, + { "QT_RAW_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath, true }, + { "QT_HOST_PREFIX", QLibraryInfo::HostPrefixPath, true }, + { "QT_HOST_DATA", QLibraryInfo::HostDataPath, true }, + { "QT_HOST_BINS", QLibraryInfo::HostBinariesPath, true }, }; QMakeProperty::QMakeProperty() : settings(0) { for (int i = 0; i < sizeof(propList)/sizeof(propList[0]); i++) - m_values[QString::fromLatin1(propList[i].name)] = - QLibraryInfo::location(propList[i].loc); + m_values[QString::fromLatin1(propList[i].name)] = propList[i].raw + ? QLibraryInfo::rawLocation(propList[i].loc) + : QLibraryInfo::location(propList[i].loc); } QMakeProperty::~QMakeProperty() -- cgit v1.2.3