ProjectExplorer: (Re-)Add run config variables

As for the build config, we provide a global variant for use by external
tools, and one for use in the respective run configuration itself.
Also hide the deprecated "CurrentRun" variant, which was forgotten in
b55825a420.

Fixes: QTCREATORBUG-25561
Change-Id: I51aaff10301f7ff1256abf1c09ac9f5be136ab00
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2021-04-08 14:17:42 +02:00
parent 24d88de228
commit 65db684c7d
3 changed files with 61 additions and 4 deletions

View File

@@ -188,6 +188,24 @@ RunConfiguration::RunConfiguration(Target *target, Utils::Id id)
BuildConfiguration *bc = target->activeBuildConfiguration();
return bc ? bc->macroExpander() : target->macroExpander();
});
m_expander.registerPrefix("RunConfig:Env", tr("Variables in the run environment"),
[this](const QString &var) {
const auto envAspect = aspect<EnvironmentAspect>();
return envAspect ? envAspect->environment().expandedValueForKey(var) : QString();
});
m_expander.registerVariable("RunConfig:WorkingDir",
tr("The run configuration's working directory"),
[this] {
const auto wdAspect = aspect<WorkingDirectoryAspect>();
return wdAspect ? wdAspect->workingDirectory(&m_expander).toString() : QString();
});
m_expander.registerVariable("RunConfig:Name", tr("The run configuration's name."),
[this] { return displayName(); });
m_expander.registerFileVariables("RunConfig:Executable",
tr("The run configuration's executable."),
[this] { return commandLine().executable().toString(); });
m_commandLineGetter = [this] {
FilePath executable;
if (const auto executableAspect = aspect<ExecutableAspect>())