forked from qt-creator/qt-creator
ProjectExplorer: Replace ProjectConfiguration::m_macroExpander
... by MacroExpanders in Build and RunConfiguration. Deploy didn't use its own, BuildStep always composed an empty expander with the BuildConfiguration's, uses now the BuildConfiguration's expander directly. Change-Id: I9de51bfc32aeb3d73f4974175e42a37807e49ac1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -86,6 +86,7 @@ public:
|
|||||||
bool m_configWidgetHasFrame = false;
|
bool m_configWidgetHasFrame = false;
|
||||||
QList<Core::Id> m_initialBuildSteps;
|
QList<Core::Id> m_initialBuildSteps;
|
||||||
QList<Core::Id> m_initialCleanSteps;
|
QList<Core::Id> m_initialCleanSteps;
|
||||||
|
Utils::MacroExpander m_macroExpander;
|
||||||
|
|
||||||
// FIXME: Remove.
|
// FIXME: Remove.
|
||||||
BuildConfiguration::BuildType m_initialBuildType = BuildConfiguration::Unknown;
|
BuildConfiguration::BuildType m_initialBuildType = BuildConfiguration::Unknown;
|
||||||
@@ -204,6 +205,11 @@ void BuildConfiguration::doInitialize(const BuildInfo &info)
|
|||||||
d->m_initializer(info);
|
d->m_initializer(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MacroExpander *BuildConfiguration::macroExpander() const
|
||||||
|
{
|
||||||
|
return &d->m_macroExpander;
|
||||||
|
}
|
||||||
|
|
||||||
void BuildConfiguration::setInitializer(const std::function<void(const BuildInfo &)> &initializer)
|
void BuildConfiguration::setInitializer(const std::function<void(const BuildInfo &)> &initializer)
|
||||||
{
|
{
|
||||||
d->m_initializer = initializer;
|
d->m_initializer = initializer;
|
||||||
|
@@ -32,6 +32,8 @@
|
|||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
|
namespace Utils { class MacroExpander; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
namespace Internal { class BuildConfigurationPrivate; }
|
namespace Internal { class BuildConfigurationPrivate; }
|
||||||
@@ -118,6 +120,8 @@ public:
|
|||||||
|
|
||||||
void doInitialize(const BuildInfo &info);
|
void doInitialize(const BuildInfo &info);
|
||||||
|
|
||||||
|
Utils::MacroExpander *macroExpander() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void environmentChanged();
|
void environmentChanged();
|
||||||
void buildDirectoryChanged();
|
void buildDirectoryChanged();
|
||||||
|
@@ -127,10 +127,6 @@ BuildStep::BuildStep(BuildStepList *bsl, Core::Id id) :
|
|||||||
ProjectConfiguration(bsl, id)
|
ProjectConfiguration(bsl, id)
|
||||||
{
|
{
|
||||||
QTC_CHECK(bsl->target() && bsl->target() == this->target());
|
QTC_CHECK(bsl->target() && bsl->target() == this->target());
|
||||||
Utils::MacroExpander *expander = macroExpander();
|
|
||||||
expander->setDisplayName(tr("Build Step"));
|
|
||||||
expander->setAccumulating(true);
|
|
||||||
expander->registerSubProvider([this] { return projectConfiguration()->macroExpander(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildStep::run()
|
void BuildStep::run()
|
||||||
@@ -220,6 +216,13 @@ BuildSystem *BuildStep::buildSystem() const
|
|||||||
return target()->buildSystem();
|
return target()->buildSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::MacroExpander *BuildStep::macroExpander() const
|
||||||
|
{
|
||||||
|
if (auto bc = buildConfiguration())
|
||||||
|
return bc->macroExpander();
|
||||||
|
return Utils::globalMacroExpander();
|
||||||
|
}
|
||||||
|
|
||||||
void BuildStep::reportRunResult(QFutureInterface<bool> &fi, bool success)
|
void BuildStep::reportRunResult(QFutureInterface<bool> &fi, bool success)
|
||||||
{
|
{
|
||||||
fi.reportResult(success);
|
fi.reportResult(success);
|
||||||
|
@@ -38,6 +38,8 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace Utils { class MacroExpander; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class BuildConfiguration;
|
class BuildConfiguration;
|
||||||
@@ -77,6 +79,7 @@ public:
|
|||||||
ProjectConfiguration *projectConfiguration() const;
|
ProjectConfiguration *projectConfiguration() const;
|
||||||
|
|
||||||
BuildSystem *buildSystem() const;
|
BuildSystem *buildSystem() const;
|
||||||
|
Utils::MacroExpander *macroExpander() const;
|
||||||
|
|
||||||
enum class OutputFormat {
|
enum class OutputFormat {
|
||||||
Stdout, Stderr, // These are for forwarded output from external tools
|
Stdout, Stderr, // These are for forwarded output from external tools
|
||||||
|
@@ -47,14 +47,6 @@ DeployConfiguration::DeployConfiguration(Target *target, Core::Id id)
|
|||||||
m_stepList(this, Constants::BUILDSTEPS_DEPLOY)
|
m_stepList(this, Constants::BUILDSTEPS_DEPLOY)
|
||||||
{
|
{
|
||||||
QTC_CHECK(target && target == this->target());
|
QTC_CHECK(target && target == this->target());
|
||||||
Utils::MacroExpander *expander = macroExpander();
|
|
||||||
expander->setDisplayName(tr("Deploy Settings"));
|
|
||||||
expander->setAccumulating(true);
|
|
||||||
expander->registerSubProvider([target] {
|
|
||||||
BuildConfiguration *bc = target->activeBuildConfiguration();
|
|
||||||
return bc ? bc->macroExpander() : target->macroExpander();
|
|
||||||
});
|
|
||||||
|
|
||||||
//: Default DeployConfiguration display name
|
//: Default DeployConfiguration display name
|
||||||
setDefaultDisplayName(tr("Deploy locally"));
|
setDefaultDisplayName(tr("Deploy locally"));
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
#include "buildstep.h"
|
#include "buildstep.h"
|
||||||
|
|
||||||
#include <QString>
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class Task;
|
class Task;
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <utils/displayname.h>
|
#include <utils/displayname.h>
|
||||||
#include <utils/macroexpander.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
@@ -188,9 +187,6 @@ public:
|
|||||||
// Note: Make sure subclasses call the superclasses' toMap() function!
|
// Note: Make sure subclasses call the superclasses' toMap() function!
|
||||||
virtual QVariantMap toMap() const;
|
virtual QVariantMap toMap() const;
|
||||||
|
|
||||||
Utils::MacroExpander *macroExpander() { return &m_macroExpander; }
|
|
||||||
const Utils::MacroExpander *macroExpander() const { return &m_macroExpander; }
|
|
||||||
|
|
||||||
Target *target() const;
|
Target *target() const;
|
||||||
Project *project() const;
|
Project *project() const;
|
||||||
|
|
||||||
@@ -223,7 +219,6 @@ private:
|
|||||||
const Core::Id m_id;
|
const Core::Id m_id;
|
||||||
Utils::DisplayName m_displayName;
|
Utils::DisplayName m_displayName;
|
||||||
QString m_toolTip;
|
QString m_toolTip;
|
||||||
Utils::MacroExpander m_macroExpander;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// helper function:
|
// helper function:
|
||||||
|
@@ -167,27 +167,26 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id)
|
|||||||
QTC_CHECK(target && target == this->target());
|
QTC_CHECK(target && target == this->target());
|
||||||
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
||||||
|
|
||||||
Utils::MacroExpander *expander = macroExpander();
|
m_expander.setDisplayName(tr("Run Settings"));
|
||||||
expander->setDisplayName(tr("Run Settings"));
|
m_expander.setAccumulating(true);
|
||||||
expander->setAccumulating(true);
|
m_expander.registerSubProvider([target] {
|
||||||
expander->registerSubProvider([target] {
|
|
||||||
BuildConfiguration *bc = target->activeBuildConfiguration();
|
BuildConfiguration *bc = target->activeBuildConfiguration();
|
||||||
return bc ? bc->macroExpander() : target->macroExpander();
|
return bc ? bc->macroExpander() : target->macroExpander();
|
||||||
});
|
});
|
||||||
expander->registerPrefix("CurrentRun:Env", tr("Variables in the current run environment"),
|
m_expander.registerPrefix("CurrentRun:Env", tr("Variables in the current run environment"),
|
||||||
[this](const QString &var) {
|
[this](const QString &var) {
|
||||||
const auto envAspect = aspect<EnvironmentAspect>();
|
const auto envAspect = aspect<EnvironmentAspect>();
|
||||||
return envAspect ? envAspect->environment().expandedValueForKey(var) : QString();
|
return envAspect ? envAspect->environment().expandedValueForKey(var) : QString();
|
||||||
});
|
});
|
||||||
|
|
||||||
expander->registerVariable(Constants::VAR_CURRENTRUN_WORKINGDIR,
|
m_expander.registerVariable(Constants::VAR_CURRENTRUN_WORKINGDIR,
|
||||||
tr("The currently active run configuration's working directory"),
|
tr("The currently active run configuration's working directory"),
|
||||||
[this, expander] {
|
[this] {
|
||||||
const auto wdAspect = aspect<WorkingDirectoryAspect>();
|
const auto wdAspect = aspect<WorkingDirectoryAspect>();
|
||||||
return wdAspect ? wdAspect->workingDirectory(expander).toString() : QString();
|
return wdAspect ? wdAspect->workingDirectory(&m_expander).toString() : QString();
|
||||||
});
|
});
|
||||||
|
|
||||||
expander->registerVariable(Constants::VAR_CURRENTRUN_NAME,
|
m_expander.registerVariable(Constants::VAR_CURRENTRUN_NAME,
|
||||||
QCoreApplication::translate("ProjectExplorer", "The currently active run configuration's name."),
|
QCoreApplication::translate("ProjectExplorer", "The currently active run configuration's name."),
|
||||||
[this] { return displayName(); }, false);
|
[this] { return displayName(); }, false);
|
||||||
|
|
||||||
@@ -232,7 +231,7 @@ QWidget *RunConfiguration::createConfigurationWidget()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::VariableChooser::addSupportForChildWidgets(widget, macroExpander());
|
Core::VariableChooser::addSupportForChildWidgets(widget, &m_expander);
|
||||||
|
|
||||||
auto detailsWidget = new Utils::DetailsWidget;
|
auto detailsWidget = new Utils::DetailsWidget;
|
||||||
detailsWidget->setState(DetailsWidget::NoSummary);
|
detailsWidget->setState(DetailsWidget::NoSummary);
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
#include <utils/macroexpander.h>
|
||||||
#include <utils/port.h>
|
#include <utils/port.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@@ -170,6 +171,8 @@ public:
|
|||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
const Utils::MacroExpander *macroExpander() const { return &m_expander; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enabledChanged();
|
void enabledChanged();
|
||||||
|
|
||||||
@@ -199,6 +202,7 @@ private:
|
|||||||
QString m_buildKey;
|
QString m_buildKey;
|
||||||
CommandLineGetter m_commandLineGetter;
|
CommandLineGetter m_commandLineGetter;
|
||||||
Updater m_updater;
|
Updater m_updater;
|
||||||
|
Utils::MacroExpander m_expander;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RunConfigurationCreationInfo
|
class RunConfigurationCreationInfo
|
||||||
|
@@ -322,7 +322,7 @@ public:
|
|||||||
IDevice::ConstPtr device;
|
IDevice::ConstPtr device;
|
||||||
Core::Id runMode;
|
Core::Id runMode;
|
||||||
Utils::Icon icon;
|
Utils::Icon icon;
|
||||||
MacroExpander *macroExpander;
|
const MacroExpander *macroExpander;
|
||||||
QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use.
|
QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use.
|
||||||
QString buildKey;
|
QString buildKey;
|
||||||
QMap<Core::Id, QVariantMap> settingsData;
|
QMap<Core::Id, QVariantMap> settingsData;
|
||||||
@@ -896,7 +896,7 @@ Kit *RunControl::kit() const
|
|||||||
return d->kit;
|
return d->kit;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroExpander *RunControl::macroExpander() const
|
const MacroExpander *RunControl::macroExpander() const
|
||||||
{
|
{
|
||||||
return d->macroExpander;
|
return d->macroExpander;
|
||||||
}
|
}
|
||||||
|
@@ -222,7 +222,7 @@ public:
|
|||||||
Target *target() const;
|
Target *target() const;
|
||||||
Project *project() const;
|
Project *project() const;
|
||||||
Kit *kit() const;
|
Kit *kit() const;
|
||||||
Utils::MacroExpander *macroExpander() const;
|
const Utils::MacroExpander *macroExpander() const;
|
||||||
ProjectConfigurationAspect *aspect(Core::Id id) const;
|
ProjectConfigurationAspect *aspect(Core::Id id) const;
|
||||||
template <typename T> T *aspect() const {
|
template <typename T> T *aspect() const {
|
||||||
return runConfiguration() ? runConfiguration()->aspect<T>() : nullptr;
|
return runConfiguration() ? runConfiguration()->aspect<T>() : nullptr;
|
||||||
|
@@ -150,17 +150,16 @@ Target::Target(Project *project, Kit *k, _constructor_tag) :
|
|||||||
connect(km, &KitManager::kitUpdated, this, &Target::handleKitUpdates);
|
connect(km, &KitManager::kitUpdated, this, &Target::handleKitUpdates);
|
||||||
connect(km, &KitManager::kitRemoved, this, &Target::handleKitRemoval);
|
connect(km, &KitManager::kitRemoved, this, &Target::handleKitRemoval);
|
||||||
|
|
||||||
Utils::MacroExpander *expander = macroExpander();
|
d->m_macroExpander.setDisplayName(tr("Target Settings"));
|
||||||
expander->setDisplayName(tr("Target Settings"));
|
d->m_macroExpander.setAccumulating(true);
|
||||||
expander->setAccumulating(true);
|
|
||||||
|
|
||||||
expander->registerSubProvider([this] { return kit()->macroExpander(); });
|
d->m_macroExpander.registerSubProvider([this] { return kit()->macroExpander(); });
|
||||||
|
|
||||||
expander->registerVariable("sourceDir", tr("Source directory"),
|
d->m_macroExpander.registerVariable("sourceDir", tr("Source directory"),
|
||||||
[project] { return project->projectDirectory().toUserOutput(); });
|
[project] { return project->projectDirectory().toUserOutput(); });
|
||||||
|
|
||||||
// Legacy support.
|
// Legacy support.
|
||||||
expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
|
d->m_macroExpander.registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
|
||||||
QCoreApplication::translate("ProjectExplorer", "Name of current project"),
|
QCoreApplication::translate("ProjectExplorer", "Name of current project"),
|
||||||
[project] { return project->displayName(); },
|
[project] { return project->displayName(); },
|
||||||
false);
|
false);
|
||||||
|
@@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QIcon)
|
QT_FORWARD_DECLARE_CLASS(QIcon)
|
||||||
|
|
||||||
|
namespace Utils { class MacroExpander; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class BuildConfiguration;
|
class BuildConfiguration;
|
||||||
class BuildTargetInfo;
|
class BuildTargetInfo;
|
||||||
|
Reference in New Issue
Block a user