diff options
| author | hjk <hjk@qt.io> | 2020-02-18 14:44:58 +0100 |
|---|---|---|
| committer | hjk <hjk@qt.io> | 2020-02-19 09:31:02 +0000 |
| commit | a68aee95a1fb1667cf912a481992870f6e60b07b (patch) | |
| tree | c4ca8649d4dc9e98231bb2dee2450b20da6a079f /src | |
| parent | e63a6744ba4d13e8bf9f8b600f8298a2baeb9260 (diff) | |
| download | qt-creator-a68aee95a1fb1667cf912a481992870f6e60b07b.tar.gz | |
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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/projectexplorer/buildconfiguration.cpp | 6 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/buildconfiguration.h | 4 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/buildstep.cpp | 11 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/buildstep.h | 3 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/deployconfiguration.cpp | 8 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/ioutputparser.h | 2 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/projectconfiguration.h | 5 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/runconfiguration.cpp | 19 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/runconfiguration.h | 4 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/runcontrol.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/runcontrol.h | 2 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/target.cpp | 11 | ||||
| -rw-r--r-- | src/plugins/projectexplorer/target.h | 2 |
13 files changed, 44 insertions, 37 deletions
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index a6262cf69d..d34d7dda1c 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -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; diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h index 00de9bb71e..3d125f5bb3 100644 --- a/src/plugins/projectexplorer/buildconfiguration.h +++ b/src/plugins/projectexplorer/buildconfiguration.h @@ -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(); diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index 930b7a6b3f..5ec896e14d 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -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); diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index 4c45fefb7f..10f8063fe3 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -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 diff --git a/src/plugins/projectexplorer/deployconfiguration.cpp b/src/plugins/projectexplorer/deployconfiguration.cpp index f410003646..e5469e9e3b 100644 --- a/src/plugins/projectexplorer/deployconfiguration.cpp +++ b/src/plugins/projectexplorer/deployconfiguration.cpp @@ -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")); } diff --git a/src/plugins/projectexplorer/ioutputparser.h b/src/plugins/projectexplorer/ioutputparser.h index 1872461cbb..cd65378fe2 100644 --- a/src/plugins/projectexplorer/ioutputparser.h +++ b/src/plugins/projectexplorer/ioutputparser.h @@ -28,7 +28,7 @@ #include "projectexplorer_export.h" #include "buildstep.h" -#include <QString> +namespace Utils { class FilePath; } namespace ProjectExplorer { class Task; diff --git a/src/plugins/projectexplorer/projectconfiguration.h b/src/plugins/projectexplorer/projectconfiguration.h index c6134f6ed8..a87a264c42 100644 --- a/src/plugins/projectexplorer/projectconfiguration.h +++ b/src/plugins/projectexplorer/projectconfiguration.h @@ -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: diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 03c908a859..8a6f7afaa4 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -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); diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 5a51508ccf..de54858abc 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -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 diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 1bd5d90f9a..0c3eecc060 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -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; } diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 1ad3e26b27..cda6d6ab55 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -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; diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index aa20d94aa8..ef8215f73f 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -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); diff --git a/src/plugins/projectexplorer/target.h b/src/plugins/projectexplorer/target.h index 2e452fac22..08ea4ef451 100644 --- a/src/plugins/projectexplorer/target.h +++ b/src/plugins/projectexplorer/target.h @@ -32,6 +32,8 @@ QT_FORWARD_DECLARE_CLASS(QIcon) +namespace Utils { class MacroExpander; } + namespace ProjectExplorer { class BuildConfiguration; class BuildTargetInfo; |
