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;
|
||||
QList<Core::Id> m_initialBuildSteps;
|
||||
QList<Core::Id> m_initialCleanSteps;
|
||||
Utils::MacroExpander m_macroExpander;
|
||||
|
||||
// FIXME: Remove.
|
||||
BuildConfiguration::BuildType m_initialBuildType = BuildConfiguration::Unknown;
|
||||
@@ -204,6 +205,11 @@ void BuildConfiguration::doInitialize(const BuildInfo &info)
|
||||
d->m_initializer(info);
|
||||
}
|
||||
|
||||
MacroExpander *BuildConfiguration::macroExpander() const
|
||||
{
|
||||
return &d->m_macroExpander;
|
||||
}
|
||||
|
||||
void BuildConfiguration::setInitializer(const std::function<void(const BuildInfo &)> &initializer)
|
||||
{
|
||||
d->m_initializer = initializer;
|
||||
|
@@ -32,6 +32,8 @@
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace Utils { class MacroExpander; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
namespace Internal { class BuildConfigurationPrivate; }
|
||||
@@ -118,6 +120,8 @@ public:
|
||||
|
||||
void doInitialize(const BuildInfo &info);
|
||||
|
||||
Utils::MacroExpander *macroExpander() const;
|
||||
|
||||
signals:
|
||||
void environmentChanged();
|
||||
void buildDirectoryChanged();
|
||||
|
@@ -127,10 +127,6 @@ BuildStep::BuildStep(BuildStepList *bsl, Core::Id id) :
|
||||
ProjectConfiguration(bsl, id)
|
||||
{
|
||||
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()
|
||||
@@ -220,6 +216,13 @@ BuildSystem *BuildStep::buildSystem() const
|
||||
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)
|
||||
{
|
||||
fi.reportResult(success);
|
||||
|
@@ -38,6 +38,8 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace Utils { class MacroExpander; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class BuildConfiguration;
|
||||
@@ -77,6 +79,7 @@ public:
|
||||
ProjectConfiguration *projectConfiguration() const;
|
||||
|
||||
BuildSystem *buildSystem() const;
|
||||
Utils::MacroExpander *macroExpander() const;
|
||||
|
||||
enum class OutputFormat {
|
||||
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)
|
||||
{
|
||||
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
|
||||
setDefaultDisplayName(tr("Deploy locally"));
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "projectexplorer_export.h"
|
||||
#include "buildstep.h"
|
||||
|
||||
#include <QString>
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Task;
|
||||
|
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <utils/displayname.h>
|
||||
#include <utils/macroexpander.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
@@ -188,9 +187,6 @@ public:
|
||||
// Note: Make sure subclasses call the superclasses' toMap() function!
|
||||
virtual QVariantMap toMap() const;
|
||||
|
||||
Utils::MacroExpander *macroExpander() { return &m_macroExpander; }
|
||||
const Utils::MacroExpander *macroExpander() const { return &m_macroExpander; }
|
||||
|
||||
Target *target() const;
|
||||
Project *project() const;
|
||||
|
||||
@@ -223,7 +219,6 @@ private:
|
||||
const Core::Id m_id;
|
||||
Utils::DisplayName m_displayName;
|
||||
QString m_toolTip;
|
||||
Utils::MacroExpander m_macroExpander;
|
||||
};
|
||||
|
||||
// helper function:
|
||||
|
@@ -167,27 +167,26 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id)
|
||||
QTC_CHECK(target && target == this->target());
|
||||
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
||||
|
||||
Utils::MacroExpander *expander = macroExpander();
|
||||
expander->setDisplayName(tr("Run Settings"));
|
||||
expander->setAccumulating(true);
|
||||
expander->registerSubProvider([target] {
|
||||
m_expander.setDisplayName(tr("Run Settings"));
|
||||
m_expander.setAccumulating(true);
|
||||
m_expander.registerSubProvider([target] {
|
||||
BuildConfiguration *bc = target->activeBuildConfiguration();
|
||||
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) {
|
||||
const auto envAspect = aspect<EnvironmentAspect>();
|
||||
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"),
|
||||
[this, expander] {
|
||||
[this] {
|
||||
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."),
|
||||
[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;
|
||||
detailsWidget->setState(DetailsWidget::NoSummary);
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "task.h"
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/port.h>
|
||||
|
||||
#include <QWidget>
|
||||
@@ -170,6 +171,8 @@ public:
|
||||
|
||||
void update();
|
||||
|
||||
const Utils::MacroExpander *macroExpander() const { return &m_expander; }
|
||||
|
||||
signals:
|
||||
void enabledChanged();
|
||||
|
||||
@@ -199,6 +202,7 @@ private:
|
||||
QString m_buildKey;
|
||||
CommandLineGetter m_commandLineGetter;
|
||||
Updater m_updater;
|
||||
Utils::MacroExpander m_expander;
|
||||
};
|
||||
|
||||
class RunConfigurationCreationInfo
|
||||
|
@@ -322,7 +322,7 @@ public:
|
||||
IDevice::ConstPtr device;
|
||||
Core::Id runMode;
|
||||
Utils::Icon icon;
|
||||
MacroExpander *macroExpander;
|
||||
const MacroExpander *macroExpander;
|
||||
QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use.
|
||||
QString buildKey;
|
||||
QMap<Core::Id, QVariantMap> settingsData;
|
||||
@@ -896,7 +896,7 @@ Kit *RunControl::kit() const
|
||||
return d->kit;
|
||||
}
|
||||
|
||||
MacroExpander *RunControl::macroExpander() const
|
||||
const MacroExpander *RunControl::macroExpander() const
|
||||
{
|
||||
return d->macroExpander;
|
||||
}
|
||||
|
@@ -222,7 +222,7 @@ public:
|
||||
Target *target() const;
|
||||
Project *project() const;
|
||||
Kit *kit() const;
|
||||
Utils::MacroExpander *macroExpander() const;
|
||||
const Utils::MacroExpander *macroExpander() const;
|
||||
ProjectConfigurationAspect *aspect(Core::Id id) const;
|
||||
template <typename T> T *aspect() const {
|
||||
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::kitRemoved, this, &Target::handleKitRemoval);
|
||||
|
||||
Utils::MacroExpander *expander = macroExpander();
|
||||
expander->setDisplayName(tr("Target Settings"));
|
||||
expander->setAccumulating(true);
|
||||
d->m_macroExpander.setDisplayName(tr("Target Settings"));
|
||||
d->m_macroExpander.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(); });
|
||||
|
||||
// Legacy support.
|
||||
expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
|
||||
d->m_macroExpander.registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
|
||||
QCoreApplication::translate("ProjectExplorer", "Name of current project"),
|
||||
[project] { return project->displayName(); },
|
||||
false);
|
||||
|
@@ -32,6 +32,8 @@
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QIcon)
|
||||
|
||||
namespace Utils { class MacroExpander; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class BuildConfiguration;
|
||||
class BuildTargetInfo;
|
||||
|
Reference in New Issue
Block a user