Utils::Environment: Use expanded values

The Environment class is supposed to support values with references to
other variables, but we failed to actually expand them in most places.

Fixes: QTCREATORBUG-22687
Change-Id: I108cb59d3b4571471423455240f6f4f1cf64bf05
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-08-19 14:29:14 +02:00
parent 30dc401429
commit 6d3f236aab
19 changed files with 58 additions and 26 deletions

View File

@@ -46,7 +46,7 @@ QProcessEnvironment Environment::toProcessEnvironment() const
QProcessEnvironment result;
for (auto it = m_values.constBegin(); it != m_values.constEnd(); ++it) {
if (it.value().second)
result.insert(it.key(), it.value().first);
result.insert(it.key(), expandedValueForKey(key(it)));
}
return result;
}
@@ -184,7 +184,7 @@ QStringList Environment::appendExeExtensions(const QString &executable) const
// Check all the executable extensions on windows:
// PATHEXT is only used if the executable has no extension
if (fi.suffix().isEmpty()) {
const QStringList extensions = value("PATHEXT").split(';');
const QStringList extensions = expandedValueForKey("PATHEXT").split(';');
for (const QString &ext : extensions)
execs << executable + ext.toLower();
@@ -212,6 +212,11 @@ bool Environment::isSameExecutable(const QString &exe1, const QString &exe2) con
return false;
}
QString Environment::expandedValueForKey(const QString &key) const
{
return expandVariables(value(key));
}
FilePath Environment::searchInPath(const QString &executable,
const FilePathList &additionalDirs,
const PathFilter &func) const
@@ -297,7 +302,7 @@ FilePathList Environment::path() const
FilePathList Environment::pathListValue(const QString &varName) const
{
const QStringList pathComponents = value(varName)
const QStringList pathComponents = expandedValueForKey(varName)
.split(OsSpecificAspects::pathListSeparator(m_osType), QString::SkipEmptyParts);
return transform(pathComponents, &FilePath::fromUserInput);
}