ProjectExplorer: Expand run environment

... before passing it to the process.

Fixes: QTCREATORBUG-33095
Change-Id: I2bbe9ed6205ae1a5b58736db86e064d5edc0b8b0
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2025-06-18 13:26:15 +02:00
parent 4983f08c47
commit 529f835c11
3 changed files with 11 additions and 1 deletions

View File

@@ -77,6 +77,15 @@ Utils::Environment EnvironmentAspect::environment() const
return env; return env;
} }
Environment EnvironmentAspect::expandedEnvironment(const Utils::MacroExpander &expander) const
{
Environment expandedEnv;
environment().forEachEntry([&](const QString &key, const QString &value, bool) {
expandedEnv.set(key, expander.expand(value));
});
return expandedEnv;
}
Environment EnvironmentAspect::modifiedBaseEnvironment() const Environment EnvironmentAspect::modifiedBaseEnvironment() const
{ {
QTC_ASSERT(m_base >= 0 && m_base < m_baseEnvironments.size(), return Environment()); QTC_ASSERT(m_base >= 0 && m_base < m_baseEnvironments.size(), return Environment());

View File

@@ -25,6 +25,7 @@ public:
// The environment including the user's modifications. // The environment including the user's modifications.
Utils::Environment environment() const; Utils::Environment environment() const;
Utils::Environment expandedEnvironment(const Utils::MacroExpander &expander) const;
// Environment including modifiers, but without explicit user changes. // Environment including modifiers, but without explicit user changes.
Utils::Environment modifiedBaseEnvironment() const; Utils::Environment modifiedBaseEnvironment() const;

View File

@@ -503,7 +503,7 @@ ProcessRunData RunConfiguration::runnable() const
if (auto workingDirectoryAspect = aspect<WorkingDirectoryAspect>()) if (auto workingDirectoryAspect = aspect<WorkingDirectoryAspect>())
r.workingDirectory = r.command.executable().withNewMappedPath(workingDirectoryAspect->workingDirectory()); r.workingDirectory = r.command.executable().withNewMappedPath(workingDirectoryAspect->workingDirectory());
if (auto environmentAspect = aspect<EnvironmentAspect>()) if (auto environmentAspect = aspect<EnvironmentAspect>())
r.environment = environmentAspect->environment(); r.environment = environmentAspect->expandedEnvironment(*macroExpander());
if (m_runnableModifier) if (m_runnableModifier)
m_runnableModifier(r); m_runnableModifier(r);