Commit 5e596e89 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

introduce qmakeProperty(), use instead of versionInfo() where applicable



the idea is to encapsulate accesses to specific variables.

Change-Id: Icafd2c85de6178db1a492a5dd36dde7f1925ea21
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 7324d1f9
......@@ -161,9 +161,10 @@ QStringList AndroidDebugSupport::qtSoPaths(QtSupport::BaseQtVersion *qtVersion)
QSet<QString> paths;
for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) {
if (!qtVersion->versionInfo().contains(QLatin1String(qMakeVariables[i])))
QString path = qtVersion->qmakeProperty(qMakeVariables[i]);
if (path.isNull())
continue;
QDirIterator it(qtVersion->versionInfo()[QLatin1String(qMakeVariables[i])], QStringList() << QLatin1String("*.so"), QDir::Files, QDirIterator::Subdirectories);
QDirIterator it(path, QStringList() << QLatin1String("*.so"), QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
it.next();
paths.insert(it.fileInfo().absolutePath());
......
......@@ -407,7 +407,7 @@ bool AndroidManager::createAndroidTemplatesIfNecessary(ProjectExplorer::Target *
return false;
Utils::FileName javaSrcPath
= Utils::FileName::fromString(version->versionInfo()[QLatin1String("QT_INSTALL_PREFIX")])
= Utils::FileName::fromString(version->qmakeProperty("QT_INSTALL_PREFIX"))
.appendPath(QLatin1String("src/android/java"));
QDir projectDir(qt4Project->projectDirectory());
Utils::FileName androidPath = dirPath(target);
......@@ -571,7 +571,7 @@ Utils::FileName AndroidManager::localLibsRulesFilePath(ProjectExplorer::Target *
QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(target->profile());
if (!version)
return Utils::FileName();
return Utils::FileName::fromString(version->versionInfo()[QLatin1String("QT_INSTALL_LIBS")] + QLatin1String("/rules.xml"));
return Utils::FileName::fromString(version->qmakeProperty("QT_INSTALL_LIBS") + QLatin1String("/rules.xml"));
}
QString AndroidManager::loadLocalLibs(ProjectExplorer::Target *target, int apiLevel)
......@@ -596,7 +596,7 @@ QStringList AndroidManager::availableQtLibs(ProjectExplorer::Target *target)
= qobject_cast<const Qt4ProjectManager::Qt4Project *>(target->project());
if (!qt4Project || !version)
return libs;
QString qtLibsPath = version->versionInfo()[QLatin1String("QT_INSTALL_LIBS")];
QString qtLibsPath = version->qmakeProperty("QT_INSTALL_LIBS");
if (!readelfPath.toFileInfo().exists()) {
QDirIterator libsIt(qtLibsPath, QStringList() << QLatin1String("libQt*.so"));
while (libsIt.hasNext()) {
......
......@@ -224,7 +224,7 @@ QString DesignDocumentController::pathToQt() const
if (activeQtVersion && (activeQtVersion->qtVersion().majorVersion > 3)
&& (activeQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|| activeQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)))
return activeQtVersion->versionInfo().value("QT_INSTALL_DATA");
return activeQtVersion->qmakeProperty("QT_INSTALL_DATA");
return QString();
}
......
......@@ -165,7 +165,7 @@ void QmlProject::refresh(RefreshOptions options)
}
if (version) {
pinfo.tryQmlDump = true;
pinfo.qtImportsPath = version->versionInfo().value("QT_INSTALL_IMPORTS");
pinfo.qtImportsPath = version->qmakeProperty("QT_INSTALL_IMPORTS");
pinfo.qtVersionString = version->qtVersionString();
}
m_modelManager->updateProjectInfo(pinfo);
......@@ -219,7 +219,7 @@ QStringList QmlProject::importPaths() const
if (runConfig) {
const QtSupport::BaseQtVersion *qtVersion = runConfig->qtVersion();
if (qtVersion && qtVersion->isValid()) {
const QString qtVersionImportPath = qtVersion->versionInfo().value("QT_INSTALL_IMPORTS");
const QString qtVersionImportPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
if (!qtVersionImportPath.isEmpty())
importPaths += qtVersionImportPath;
}
......
......@@ -623,7 +623,7 @@ Utils::Environment Qt4RunConfiguration::baseEnvironment() const
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtProfileInformation::qtVersion(target()->profile());
if (qtVersion)
env.prependOrSetLibrarySearchPath(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_LIBS")));
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
return env;
}
......
......@@ -503,7 +503,7 @@ Utils::FileName Qt4BuildConfiguration::extractSpecFromArguments(QString *args,
return Utils::FileName();
Utils::FileName baseMkspecDir = Utils::FileName::fromUserInput(
version->versionInfo().value(QLatin1String("QT_HOST_DATA")) + QLatin1String("/mkspecs"));
version->qmakeProperty("QT_HOST_DATA") + QLatin1String("/mkspecs"));
// if the path is relative it can be
// relative to the working directory (as found in the Makefiles)
......
......@@ -606,7 +606,7 @@ void Qt4Project::updateQmlJSCodeModel()
if (qtVersion && qtVersion->isValid()) {
projectInfo.tryQmlDump = qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|| qtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT);
projectInfo.qtImportsPath = qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_IMPORTS"));
projectInfo.qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
if (!projectInfo.qtImportsPath.isEmpty())
projectInfo.importPaths += projectInfo.qtImportsPath;
projectInfo.qtVersionString = qtVersion->qtVersionString();
......
......@@ -207,9 +207,7 @@ void Qt4Manager::updateVariable(const QByteArray &variable)
qtv = QtSupport::QtProfileInformation::qtVersion(ProjectExplorer::ProfileManager::instance()->defaultProfile());
if (qtv)
value = qtv->versionInfo().value(variable == kHostBins
? QLatin1String("QT_HOST_BINS")
: QLatin1String("QT_INSTALL_BINS"));
value = qtv->qmakeProperty(variable == kHostBins ? "QT_HOST_BINS" : "QT_INSTALL_BINS");
Core::VariableManager::instance()->insert(variable, value);
}
}
......
......@@ -362,7 +362,7 @@ bool BaseQtVersion::isValid() const
return !qmakeCommand().isEmpty()
&& m_installed
&& m_versionInfo.contains(QLatin1String("QT_HOST_BINS"))
&& !qmakeProperty("QT_HOST_BINS").isNull()
&& !m_mkspecFullPath.isEmpty()
&& m_qmakeIsExecutable;
}
......@@ -377,7 +377,7 @@ QString BaseQtVersion::invalidReason() const
return QCoreApplication::translate("QtVersion", "qmake does not exist or is not executable");
if (!m_installed)
return QCoreApplication::translate("QtVersion", "Qt version is not properly installed, please run make install");
if (!m_versionInfo.contains(QLatin1String("QT_HOST_BINS")))
if (qmakeProperty("QT_HOST_BINS").isNull())
return QCoreApplication::translate("QtVersion",
"Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?");
if (m_mkspecUpToDate && m_mkspecFullPath.isEmpty())
......@@ -533,7 +533,7 @@ void BaseQtVersion::updateSourcePath() const
if (!m_sourcePath.isEmpty())
return;
updateVersionInfo();
const QString installData = m_versionInfo.value(QLatin1String("QT_INSTALL_PREFIX"));
const QString installData = qmakeProperty("QT_INSTALL_PREFIX");
QString sourcePath = installData;
QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
if (qmakeCache.exists()) {
......@@ -592,7 +592,7 @@ QString BaseQtVersion::findQtBinary(Binaries binary) const
{
QString baseDir;
if (qtVersion() < QtVersionNumber(5, 0, 0)) {
baseDir = versionInfo().value(QLatin1String("QT_HOST_BINS"));
baseDir = qmakeProperty("QT_HOST_BINS");
} else {
ensureMkSpecParsed();
switch (binary) {
......@@ -604,7 +604,7 @@ QString BaseQtVersion::findQtBinary(Binaries binary) const
baseDir = m_mkspecValues.value(QLatin1String("QT.designer.bins"));
break;
case Uic:
baseDir = versionInfo().value(QLatin1String("QT_HOST_BINS"));
baseDir = qmakeProperty("QT_HOST_BINS");
break;
default:
// Can't happen
......@@ -783,7 +783,7 @@ bool BaseQtVersion::hasMkspec(const Utils::FileName &spec) const
{
updateVersionInfo();
QFileInfo fi;
fi.setFile(QDir::fromNativeSeparators(m_versionInfo.value(QLatin1String("QT_HOST_DATA")))
fi.setFile(QDir::fromNativeSeparators(qmakeProperty("QT_HOST_DATA"))
+ QLatin1String("/mkspecs/") + spec.toString());
if (fi.isDir())
return true;
......@@ -837,13 +837,10 @@ void BaseQtVersion::updateVersionInfo() const
if (!queryQMakeVariables(qmakeCommand(), &m_versionInfo, &m_qmakeIsExecutable))
return;
const QString installDataKey = QLatin1String("QT_INSTALL_DATA");
const QString installBinsKey = QLatin1String("QT_INSTALL_BINS");
const QString installHeadersKey = QLatin1String("QT_INSTALL_HEADERS");
if (m_versionInfo.contains(installDataKey)) {
const QString qtInstallData = m_versionInfo.value(installDataKey);
const QString qtInstallBins = m_versionInfo.value(installBinsKey);
const QString qtHeaderData = m_versionInfo.value(installHeadersKey);
const QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
const QString qtInstallBins = qmakeProperty("QT_INSTALL_BINS");
const QString qtHeaderData = qmakeProperty("QT_INSTALL_HEADERS");
if (!qtInstallData.isNull()) {
if (!qtInstallData.isEmpty()) {
m_hasDebuggingHelper = !QtSupport::DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData).isEmpty();
m_hasQmlDump
......@@ -857,35 +854,35 @@ void BaseQtVersion::updateVersionInfo() const
}
// Now check for a qt that is configured with a prefix but not installed
if (m_versionInfo.contains(installBinsKey)) {
QFileInfo fi(m_versionInfo.value(installBinsKey));
if (!qtInstallBins.isNull()) {
QFileInfo fi(qtInstallBins);
if (!fi.exists())
m_installed = false;
}
if (m_versionInfo.contains(installHeadersKey)) {
const QFileInfo fi(m_versionInfo.value(installHeadersKey));
if (!qtHeaderData.isNull()) {
const QFileInfo fi(qtHeaderData);
if (!fi.exists())
m_installed = false;
}
const QString installDocsKey = QLatin1String("QT_INSTALL_DOCS");
if (m_versionInfo.contains(installDocsKey)) {
const QFileInfo fi(m_versionInfo.value(installDocsKey));
const QString qtInstallDocs = qmakeProperty("QT_INSTALL_DOCS");
if (!qtInstallDocs.isNull()) {
const QFileInfo fi(qtInstallDocs);
if (fi.exists())
m_hasDocumentation = true;
}
const QString installExamplesKey = QLatin1String("QT_INSTALL_EXAMPLES");
if (m_versionInfo.contains(installExamplesKey)) {
const QFileInfo fi(m_versionInfo.value(installExamplesKey));
const QString qtInstallExamples = qmakeProperty("QT_INSTALL_EXAMPLES");
if (!qtInstallExamples.isNull()) {
const QFileInfo fi(qtInstallExamples);
if (fi.exists())
m_hasExamples = true;
}
const QString installDemosKey = QLatin1String("QT_INSTALL_DEMOS");
if (m_versionInfo.contains(installDemosKey)) {
const QFileInfo fi(m_versionInfo.value(installDemosKey));
const QString qtInstallDemos = qmakeProperty("QT_INSTALL_DEMOS");
if (!qtInstallDemos.isNull()) {
const QFileInfo fi(qtInstallDemos);
if (fi.exists())
m_hasDemos = true;
}
m_qtVersionString = m_versionInfo.value(QLatin1String("QT_VERSION"), QString());
m_qtVersionString = qmakeProperty("QT_VERSION");
m_versionInfoUpToDate = true;
}
......@@ -896,6 +893,16 @@ QHash<QString,QString> BaseQtVersion::versionInfo() const
return m_versionInfo;
}
QString BaseQtVersion::qmakeProperty(const QHash<QString,QString> &versionInfo, const QByteArray &name)
{
return versionInfo.value(QString::fromLatin1(name));
}
QString BaseQtVersion::qmakeProperty(const QByteArray &name) const
{
return qmakeProperty(m_versionInfo, name);
}
bool BaseQtVersion::hasDocumentation() const
{
updateVersionInfo();
......@@ -905,7 +912,7 @@ bool BaseQtVersion::hasDocumentation() const
QString BaseQtVersion::documentationPath() const
{
updateVersionInfo();
return m_versionInfo.value(QLatin1String("QT_INSTALL_DOCS"));
return qmakeProperty("QT_INSTALL_DOCS");
}
bool BaseQtVersion::hasDemos() const
......@@ -917,7 +924,7 @@ bool BaseQtVersion::hasDemos() const
QString BaseQtVersion::demosPath() const
{
updateVersionInfo();
return m_versionInfo.value(QLatin1String("QT_INSTALL_DEMOS"));
return qmakeProperty("QT_INSTALL_DEMOS");
}
QString BaseQtVersion::frameworkInstallPath() const
......@@ -939,7 +946,7 @@ bool BaseQtVersion::hasExamples() const
QString BaseQtVersion::examplesPath() const
{
updateVersionInfo();
return m_versionInfo.value(QLatin1String("QT_INSTALL_EXAMPLES"));
return qmakeProperty("QT_INSTALL_EXAMPLES");
}
QList<ProjectExplorer::HeaderPath> BaseQtVersion::systemHeaderPathes(const ProjectExplorer::Profile *p) const
......@@ -953,8 +960,8 @@ QList<ProjectExplorer::HeaderPath> BaseQtVersion::systemHeaderPathes(const Proje
void BaseQtVersion::addToEnvironment(const ProjectExplorer::Profile *p, Utils::Environment &env) const
{
Q_UNUSED(p);
env.set(QLatin1String("QTDIR"), QDir::toNativeSeparators(versionInfo().value(QLatin1String("QT_HOST_DATA"))));
env.prependOrSetPath(versionInfo().value(QLatin1String("QT_HOST_BINS")));
env.set(QLatin1String("QTDIR"), QDir::toNativeSeparators(qmakeProperty("QT_HOST_DATA")));
env.prependOrSetPath(qmakeProperty("QT_HOST_BINS"));
}
bool BaseQtVersion::hasGdbDebuggingHelper() const
......@@ -1015,7 +1022,7 @@ Utils::Environment BaseQtVersion::qmlToolsEnvironment() const
QString BaseQtVersion::gdbDebuggingHelperLibrary() const
{
QString qtInstallData = versionInfo().value(QLatin1String("QT_INSTALL_DATA"));
QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return QString();
return QtSupport::DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData);
......@@ -1023,17 +1030,17 @@ QString BaseQtVersion::gdbDebuggingHelperLibrary() const
QString BaseQtVersion::qmlDumpTool(bool debugVersion) const
{
const QString qtInstallData = versionInfo().value(QLatin1String("QT_INSTALL_DATA"));
const QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return QString();
const QString qtInstallBins = versionInfo().value(QLatin1String("QT_INSTALL_BINS"));
const QString qtHeaderData = versionInfo().value(QLatin1String("QT_INSTALL_HEADERS"));
const QString qtInstallBins = qmakeProperty("QT_INSTALL_BINS");
const QString qtHeaderData = qmakeProperty("QT_INSTALL_HEADERS");
return QmlDumpTool::toolForQtPaths(qtInstallData, qtInstallBins, qtHeaderData, debugVersion);
}
QString BaseQtVersion::qmlDebuggingHelperLibrary(bool debugVersion) const
{
QString qtInstallData = versionInfo().value(QLatin1String("QT_INSTALL_DATA"));
QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return QString();
return QmlDebuggingLibrary::libraryByInstallData(qtInstallData, debugVersion);
......@@ -1041,7 +1048,7 @@ QString BaseQtVersion::qmlDebuggingHelperLibrary(bool debugVersion) const
QString BaseQtVersion::qmlObserverTool() const
{
QString qtInstallData = versionInfo().value(QLatin1String("QT_INSTALL_DATA"));
QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return QString();
return QmlObserverTool::toolByInstallData(qtInstallData);
......@@ -1049,7 +1056,7 @@ QString BaseQtVersion::qmlObserverTool() const
QStringList BaseQtVersion::debuggingHelperLibraryLocations() const
{
QString qtInstallData = versionInfo().value(QLatin1String("QT_INSTALL_DATA"));
QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return QStringList();
return QtSupport::DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
......@@ -1175,6 +1182,8 @@ bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash<QSt
if (index != -1) {
QString name = line.left(index);
QString value = QDir::fromNativeSeparators(line.mid(index+1));
if (value.isNull())
value = QLatin1String(""); // Make sure it is not null, to discern from missing keys
versionInfo->insert(name, value);
if (name.startsWith(QLatin1String("QT_")) && !name.contains(QLatin1Char('/'))) {
if (name.startsWith(QLatin1String("QT_INSTALL_"))) {
......@@ -1198,7 +1207,7 @@ bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash<QSt
Utils::FileName BaseQtVersion::mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo)
{
QString dataDir = versionInfo.value(QLatin1String("QT_HOST_DATA"));
QString dataDir = qmakeProperty(versionInfo, "QT_HOST_DATA");
if (dataDir.isEmpty())
return Utils::FileName();
return Utils::FileName::fromUserInput(dataDir + QLatin1String("/mkspecs"));
......@@ -1265,8 +1274,8 @@ Utils::FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QStrin
Utils::FileName BaseQtVersion::qtCorePath(const QHash<QString,QString> &versionInfo, const QString &versionString)
{
QStringList dirs;
dirs << versionInfo.value(QLatin1String("QT_INSTALL_LIBS"))
<< versionInfo.value(QLatin1String("QT_INSTALL_BINS"));
dirs << qmakeProperty(versionInfo, "QT_INSTALL_LIBS")
<< qmakeProperty(versionInfo, "QT_INSTALL_BINS");
QFileInfoList staticLibs;
foreach (const QString &dir, dirs) {
......
......@@ -133,6 +133,8 @@ public:
// Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information
QHash<QString,QString> versionInfo() const;
static QString qmakeProperty(const QHash<QString,QString> &versionInfo, const QByteArray &name);
QString qmakeProperty(const QByteArray &name) const;
virtual void addToEnvironment(const ProjectExplorer::Profile *p, Utils::Environment &env) const;
virtual Utils::FileName sourcePath() const;
......
......@@ -75,7 +75,7 @@ DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version,
// of the version pointer while compiling
//
m_qtId = version->uniqueId();
m_qtInstallData = version->versionInfo().value(QLatin1String("QT_INSTALL_DATA"));
m_qtInstallData = version->qmakeProperty("QT_INSTALL_DATA");
if (m_qtInstallData.isEmpty()) {
const QString error
= QCoreApplication::translate(
......
......@@ -196,7 +196,7 @@ static bool hasPrivateHeaders(const QString &qtInstallHeaders) {
bool QmlDumpTool::canBuild(const BaseQtVersion *qtVersion, QString *reason)
{
const QString installHeaders = qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_HEADERS"));
const QString installHeaders = qtVersion->qmakeProperty("QT_INSTALL_HEADERS");
if (qtVersion->type() != QLatin1String(Constants::DESKTOPQT)
&& qtVersion->type() != QLatin1String(Constants::SIMULATORQT)) {
......@@ -227,9 +227,9 @@ bool QmlDumpTool::canBuild(const BaseQtVersion *qtVersion, QString *reason)
QString QmlDumpTool::toolForVersion(BaseQtVersion *version, bool debugDump)
{
if (version) {
const QString qtInstallData = version->versionInfo().value(QLatin1String("QT_INSTALL_DATA"));
const QString qtInstallBins = version->versionInfo().value(QLatin1String("QT_INSTALL_BINS"));
const QString qtInstallHeaders = version->versionInfo().value(QLatin1String("QT_INSTALL_HEADERS"));
const QString qtInstallData = version->qmakeProperty("QT_INSTALL_DATA");
const QString qtInstallBins = version->qmakeProperty("QT_INSTALL_BINS");
const QString qtInstallHeaders = version->qmakeProperty("QT_INSTALL_HEADERS");
return toolForQtPaths(qtInstallData, qtInstallBins, qtInstallHeaders, debugDump);
}
......
Markdown is supported
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