From b94a6a05376eb1c645f2493a28f4a9a71c551de1 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 5 Nov 2014 15:45:56 +0100 Subject: [PATCH] Set up hierarchy of ProjectConfiguration macro expanders. BuildConfiguration asks Target, Deploy and Run ask either activeBuild, or Target. Change-Id: I3845cfbd16de7b85268d83b5324865ff24482152 Reviewed-by: Tobias Hunger --- .../projectexplorer/buildconfiguration.cpp | 19 +++++++++++++++++-- .../projectexplorer/buildconfiguration.h | 1 + .../projectexplorer/deployconfiguration.cpp | 16 ++++++++++++++-- .../projectexplorer/deployconfiguration.h | 2 ++ .../localapplicationrunconfiguration.cpp | 15 --------------- .../localapplicationrunconfiguration.h | 3 --- .../projectexplorer/runconfiguration.cpp | 8 +++++++- src/plugins/projectexplorer/target.cpp | 17 +++++------------ 8 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index b157ba3d93c..d4a90fb0792 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -76,7 +76,7 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) : this, SLOT(handleKitUpdate())); connect(this, SIGNAL(environmentChanged()), this, SLOT(emitBuildDirectoryChanged())); - macroExpander()->registerSubProvider([target] { return target->macroExpander(); }); + ctor(); } BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) : @@ -95,7 +95,22 @@ BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *sourc connect(target, SIGNAL(kitChanged()), this, SLOT(handleKitUpdate())); - macroExpander()->registerSubProvider([target] { return target->macroExpander(); }); + ctor(); +} + +void BuildConfiguration::ctor() +{ + Utils::MacroExpander *expander = macroExpander(); + expander->setDisplayName(tr("Build Settings")); + expander->setAccumulating(true); + expander->registerSubProvider([this] { return target()->macroExpander(); }); + + expander->registerVariable("buildDir", tr("Build directory"), + [this] { return buildDirectory().toUserOutput(); }); + + expander->registerVariable(Constants::VAR_CURRENTBUILD_NAME, + QCoreApplication::translate("ProjectExplorer", "Name of current build"), + [this] { return displayName(); }, false); } BuildConfiguration::~BuildConfiguration() diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h index cc8b17ecdeb..313cc97f2e4 100644 --- a/src/plugins/projectexplorer/buildconfiguration.h +++ b/src/plugins/projectexplorer/buildconfiguration.h @@ -107,6 +107,7 @@ private slots: private: void emitEnvironmentChanged(); + void ctor(); bool m_clearSystemEnvironment; QList m_userEnvironmentChanges; diff --git a/src/plugins/projectexplorer/deployconfiguration.cpp b/src/plugins/projectexplorer/deployconfiguration.cpp index b777a77f9e2..1c39a177b52 100644 --- a/src/plugins/projectexplorer/deployconfiguration.cpp +++ b/src/plugins/projectexplorer/deployconfiguration.cpp @@ -31,6 +31,7 @@ #include "deployconfiguration.h" #include "buildsteplist.h" +#include "buildconfiguration.h" #include "kitinformation.h" #include "project.h" #include "projectexplorer.h" @@ -53,7 +54,7 @@ DeployConfiguration::DeployConfiguration(Target *target, Core::Id id) : m_stepList->setDefaultDisplayName(tr("Deploy")); //: Default DeployConfiguration display name setDefaultDisplayName(tr("Deploy locally")); - macroExpander()->registerSubProvider([target] { return target->macroExpander(); }); + ctor(); } DeployConfiguration::DeployConfiguration(Target *target, DeployConfiguration *source) : @@ -64,7 +65,18 @@ DeployConfiguration::DeployConfiguration(Target *target, DeployConfiguration *so // Do not clone stepLists here, do that in the derived constructor instead // otherwise BuildStepFactories might reject to set up a BuildStep for us // since we are not yet the derived class! - macroExpander()->registerSubProvider([target] { return target->macroExpander(); }); + ctor(); +} + +void DeployConfiguration::ctor() +{ + Utils::MacroExpander *expander = macroExpander(); + expander->setDisplayName(tr("Deploy Settings")); + expander->setAccumulating(true); + expander->registerSubProvider([this]() -> Utils::MacroExpander * { + BuildConfiguration *bc = target()->activeBuildConfiguration(); + return bc ? bc->macroExpander() : target()->macroExpander(); + }); } DeployConfiguration::~DeployConfiguration() diff --git a/src/plugins/projectexplorer/deployconfiguration.h b/src/plugins/projectexplorer/deployconfiguration.h index f7500d1d088..aed56110912 100644 --- a/src/plugins/projectexplorer/deployconfiguration.h +++ b/src/plugins/projectexplorer/deployconfiguration.h @@ -76,6 +76,8 @@ protected: void cloneSteps(DeployConfiguration *source); private: + void ctor(); + BuildStepList *m_stepList; }; diff --git a/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp b/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp index 6c02c78c3c7..99e32555c6f 100644 --- a/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp +++ b/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp @@ -44,13 +44,11 @@ namespace ProjectExplorer { LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - setupMacroExpander(); } LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc) : RunConfiguration(target, rc) { - setupMacroExpander(); } LocalApplicationRunConfiguration::~LocalApplicationRunConfiguration() @@ -62,17 +60,4 @@ void LocalApplicationRunConfiguration::addToBaseEnvironment(Utils::Environment & Q_UNUSED(env); } -void LocalApplicationRunConfiguration::setupMacroExpander() -{ - // Legacy - macroExpander()->registerSubProvider([this]() -> Utils::MacroExpander * { - if (BuildConfiguration *bc = activeBuildConfiguration()) - return bc->macroExpander(); - return 0; - }); - - macroExpander()->registerVariable("sourceDir", tr("Project source directory"), - [this] { return target()->project()->projectDirectory().toUserOutput(); }); -} - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/localapplicationrunconfiguration.h b/src/plugins/projectexplorer/localapplicationrunconfiguration.h index d9b6d15dacf..52bc7670034 100644 --- a/src/plugins/projectexplorer/localapplicationrunconfiguration.h +++ b/src/plugins/projectexplorer/localapplicationrunconfiguration.h @@ -54,9 +54,6 @@ public: protected: explicit LocalApplicationRunConfiguration(Target *target, Core::Id id); explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc); - -private: - void setupMacroExpander(); }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 1d1b7b637b6..3429c483fea 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -254,7 +254,13 @@ void RunConfiguration::ctor() { connect(this, SIGNAL(enabledChanged()), this, SIGNAL(requestRunActionsUpdate())); - macroExpander()->registerSubProvider([this] { return target()->macroExpander(); }); + Utils::MacroExpander *expander = macroExpander(); + expander->setDisplayName(tr("Run Settings")); + expander->setAccumulating(true); + expander->registerSubProvider([this]() -> Utils::MacroExpander * { + BuildConfiguration *bc = target()->activeBuildConfiguration(); + return bc ? bc->macroExpander() : target()->macroExpander(); + }); } /*! diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index 32b1e52f64a..4569ea28efc 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -140,27 +140,20 @@ Target::Target(Project *project, Kit *k) : this, SLOT(handleKitRemoval(ProjectExplorer::Kit*))); Utils::MacroExpander *expander = macroExpander(); + expander->setDisplayName(tr("Target Settings")); + expander->setAccumulating(true); expander->registerSubProvider([this] { return kit()->macroExpander(); }); + expander->registerVariable("sourceDir", tr("Source directory"), + [project] { return project->projectDirectory().toUserOutput(); }); + // Legacy support. expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME, QCoreApplication::translate("ProjectExplorer", "Name of current project"), [project] { return project->displayName(); }, false); - expander->registerVariable(Constants::VAR_CURRENTBUILD_NAME, - QCoreApplication::translate("ProjectExplorer", "Name of current build"), - [this] { return activeBuildConfiguration() ? activeBuildConfiguration()->displayName() : QString(); }, - false); - - expander->registerVariable("sourceDir", tr("Source directory"), - [project] { return project->projectDirectory().toUserOutput(); }); - - expander->registerVariable("buildDir", tr("Build directory"), - [this] { return activeBuildConfiguration() - ? activeBuildConfiguration()->buildDirectory().toUserOutput() - : QString() ; }); } Target::~Target()