Variable manager: Add convenience method for expanding string.

Change-Id: I0e2cf4a9d39142ab3ae4c6cedb2d917822d1c1f5
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Eike Ziller
2013-03-13 14:25:47 +01:00
committed by hjk
parent c8421e66b6
commit 3a042b87a2
3 changed files with 10 additions and 6 deletions

View File

@@ -555,8 +555,7 @@ bool ExternalToolRunner::resolve()
{ // executable { // executable
QStringList expandedExecutables; /* for error message */ QStringList expandedExecutables; /* for error message */
foreach (const QString &executable, m_tool->executables()) { foreach (const QString &executable, m_tool->executables()) {
QString expanded = Utils::expandMacros(executable, QString expanded = Core::VariableManager::expandedString(executable);
Core::VariableManager::macroExpander());
expandedExecutables << expanded; expandedExecutables << expanded;
m_resolvedExecutable = m_resolvedExecutable =
Utils::Environment::systemEnvironment().searchInPath(expanded); Utils::Environment::systemEnvironment().searchInPath(expanded);
@@ -580,12 +579,10 @@ bool ExternalToolRunner::resolve()
Core::VariableManager::macroExpander()); Core::VariableManager::macroExpander());
} }
{ // input { // input
m_resolvedInput = Utils::expandMacros(m_tool->input(), m_resolvedInput = Core::VariableManager::expandedString(m_tool->input());
Core::VariableManager::macroExpander());
} }
{ // working directory { // working directory
m_resolvedWorkingDirectory = Utils::expandMacros(m_tool->workingDirectory(), m_resolvedWorkingDirectory = Core::VariableManager::expandedString(m_tool->workingDirectory());
Core::VariableManager::macroExpander());
} }
return true; return true;
} }

View File

@@ -110,6 +110,11 @@ QString VariableManager::value(const QByteArray &variable, bool *found)
return d->m_map.value(variable); return d->m_map.value(variable);
} }
QString VariableManager::expandedString(const QString &stringWithVariables)
{
return Utils::expandMacros(stringWithVariables, macroExpander());
}
Utils::AbstractMacroExpander *VariableManager::macroExpander() Utils::AbstractMacroExpander *VariableManager::macroExpander()
{ {
return &d->m_macroExpander; return &d->m_macroExpander;

View File

@@ -57,6 +57,8 @@ public:
static void insert(const QByteArray &variable, const QString &value); static void insert(const QByteArray &variable, const QString &value);
static bool remove(const QByteArray &variable); static bool remove(const QByteArray &variable);
static QString value(const QByteArray &variable, bool *found = 0); static QString value(const QByteArray &variable, bool *found = 0);
static QString expandedString(const QString &stringWithVariables);
static Utils::AbstractMacroExpander *macroExpander(); static Utils::AbstractMacroExpander *macroExpander();
static void registerVariable(const QByteArray &variable, static void registerVariable(const QByteArray &variable,