ProjectExplorer: Add CurrentRun:Env to the MacroExpander

Make RunConfigurations provide %{CurrentRun:Env:VARNAME} via the
macro expander infrastructure.

Change-Id: Ibf2d9d507294f0bc9a51a1521884b364e0c7955d
Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-01-25 16:18:30 +01:00
parent 4672624bdc
commit 468695c30a
2 changed files with 7 additions and 0 deletions

View File

@@ -30,6 +30,7 @@
#include "toolchain.h"
#include "abi.h"
#include "buildconfiguration.h"
#include "environmentaspect.h"
#include "kitinformation.h"
#include <extensionsystem/pluginmanager.h>
@@ -215,6 +216,11 @@ void RunConfiguration::ctor()
BuildConfiguration *bc = target()->activeBuildConfiguration();
return bc ? bc->macroExpander() : target()->macroExpander();
});
expander->registerPrefix(Constants::VAR_CURRENTRUN_ENV, tr("Variables in the current run environment"),
[this](const QString &var) {
const auto envAspect = extraAspect<EnvironmentAspect>();
return envAspect ? envAspect->environment().value(var) : QString();
});
expander->registerVariable(Constants::VAR_CURRENTRUN_NAME,
QCoreApplication::translate("ProjectExplorer", "The currently active run configuration's name."),
[this] { return displayName(); }, false);