forked from qt-creator/qt-creator
ProjectExplorer: Simplify LocalEnvspect's BaseEnvironmentModifier
The run configuration is known at setup time, and fixed. Change-Id: Iad7837bf39fb5eeed49bd71b7f14b9692014ea9d Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -44,11 +44,11 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id)
|
|||||||
: RunConfiguration(target, id)
|
: RunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
// Workaround for QTCREATORBUG-19354:
|
// Workaround for QTCREATORBUG-19354:
|
||||||
auto cmakeRunEnvironmentModifier = [](RunConfiguration *rc, Utils::Environment &env) {
|
auto cmakeRunEnvironmentModifier = [target](Utils::Environment &env) {
|
||||||
if (!Utils::HostOsInfo::isWindowsHost() || !rc)
|
if (!Utils::HostOsInfo::isWindowsHost())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Kit *k = rc->target()->kit();
|
const Kit *k = target->kit();
|
||||||
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(k);
|
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(k);
|
||||||
if (qt)
|
if (qt)
|
||||||
env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS"));
|
env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS"));
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Utils::Environment LocalEnvironmentAspect::baseEnvironment() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_baseEnvironmentModifier)
|
if (m_baseEnvironmentModifier)
|
||||||
m_baseEnvironmentModifier(runConfiguration(), env);
|
m_baseEnvironmentModifier(env);
|
||||||
|
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class PROJECTEXPLORER_EXPORT LocalEnvironmentAspect : public EnvironmentAspect
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::function<void(RunConfiguration *, Utils::Environment &)> BaseEnvironmentModifier;
|
typedef std::function<void(Utils::Environment &)> BaseEnvironmentModifier;
|
||||||
LocalEnvironmentAspect(RunConfiguration *parent, const BaseEnvironmentModifier &modifier);
|
LocalEnvironmentAspect(RunConfiguration *parent, const BaseEnvironmentModifier &modifier);
|
||||||
|
|
||||||
Utils::Environment baseEnvironment() const override;
|
Utils::Environment baseEnvironment() const override;
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id)
|
|||||||
: RunConfiguration(target, id)
|
: RunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
auto envAspect = addAspect<LocalEnvironmentAspect>(
|
auto envAspect = addAspect<LocalEnvironmentAspect>(
|
||||||
[](RunConfiguration *rc, Environment &env) {
|
[this](Environment &env) { addToBaseEnvironment(env); });
|
||||||
static_cast<QbsRunConfiguration *>(rc)->addToBaseEnvironment(env);
|
|
||||||
});
|
|
||||||
|
|
||||||
addAspect<ExecutableAspect>();
|
addAspect<ExecutableAspect>();
|
||||||
addAspect<ArgumentsAspect>();
|
addAspect<ArgumentsAspect>();
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile";
|
|||||||
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target, Core::Id id)
|
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target, Core::Id id)
|
||||||
: RunConfiguration(target, id)
|
: RunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
auto envAspect = addAspect<LocalEnvironmentAspect>([](RunConfiguration *rc, Environment &env) {
|
auto envAspect = addAspect<LocalEnvironmentAspect>([this](Environment &env) {
|
||||||
static_cast<DesktopQmakeRunConfiguration *>(rc)->addToBaseEnvironment(env);
|
addToBaseEnvironment(env);
|
||||||
});
|
});
|
||||||
|
|
||||||
addAspect<ExecutableAspect>();
|
addAspect<ExecutableAspect>();
|
||||||
|
|||||||
Reference in New Issue
Block a user