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 <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2014-11-05 15:45:56 +01:00
parent d8edeb1e38
commit b94a6a0537
8 changed files with 46 additions and 35 deletions

View File

@@ -76,7 +76,7 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) :
this, SLOT(handleKitUpdate())); this, SLOT(handleKitUpdate()));
connect(this, SIGNAL(environmentChanged()), this, SLOT(emitBuildDirectoryChanged())); connect(this, SIGNAL(environmentChanged()), this, SLOT(emitBuildDirectoryChanged()));
macroExpander()->registerSubProvider([target] { return target->macroExpander(); }); ctor();
} }
BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) : BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) :
@@ -95,7 +95,22 @@ BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *sourc
connect(target, SIGNAL(kitChanged()), connect(target, SIGNAL(kitChanged()),
this, SLOT(handleKitUpdate())); 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() BuildConfiguration::~BuildConfiguration()

View File

@@ -107,6 +107,7 @@ private slots:
private: private:
void emitEnvironmentChanged(); void emitEnvironmentChanged();
void ctor();
bool m_clearSystemEnvironment; bool m_clearSystemEnvironment;
QList<Utils::EnvironmentItem> m_userEnvironmentChanges; QList<Utils::EnvironmentItem> m_userEnvironmentChanges;

View File

@@ -31,6 +31,7 @@
#include "deployconfiguration.h" #include "deployconfiguration.h"
#include "buildsteplist.h" #include "buildsteplist.h"
#include "buildconfiguration.h"
#include "kitinformation.h" #include "kitinformation.h"
#include "project.h" #include "project.h"
#include "projectexplorer.h" #include "projectexplorer.h"
@@ -53,7 +54,7 @@ DeployConfiguration::DeployConfiguration(Target *target, Core::Id id) :
m_stepList->setDefaultDisplayName(tr("Deploy")); m_stepList->setDefaultDisplayName(tr("Deploy"));
//: Default DeployConfiguration display name //: Default DeployConfiguration display name
setDefaultDisplayName(tr("Deploy locally")); setDefaultDisplayName(tr("Deploy locally"));
macroExpander()->registerSubProvider([target] { return target->macroExpander(); }); ctor();
} }
DeployConfiguration::DeployConfiguration(Target *target, DeployConfiguration *source) : 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 // Do not clone stepLists here, do that in the derived constructor instead
// otherwise BuildStepFactories might reject to set up a BuildStep for us // otherwise BuildStepFactories might reject to set up a BuildStep for us
// since we are not yet the derived class! // 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() DeployConfiguration::~DeployConfiguration()

View File

@@ -76,6 +76,8 @@ protected:
void cloneSteps(DeployConfiguration *source); void cloneSteps(DeployConfiguration *source);
private: private:
void ctor();
BuildStepList *m_stepList; BuildStepList *m_stepList;
}; };

View File

@@ -44,13 +44,11 @@ namespace ProjectExplorer {
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, Core::Id id) : LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, Core::Id id) :
RunConfiguration(target, id) RunConfiguration(target, id)
{ {
setupMacroExpander();
} }
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc) : LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc) :
RunConfiguration(target, rc) RunConfiguration(target, rc)
{ {
setupMacroExpander();
} }
LocalApplicationRunConfiguration::~LocalApplicationRunConfiguration() LocalApplicationRunConfiguration::~LocalApplicationRunConfiguration()
@@ -62,17 +60,4 @@ void LocalApplicationRunConfiguration::addToBaseEnvironment(Utils::Environment &
Q_UNUSED(env); 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 } // namespace ProjectExplorer

View File

@@ -54,9 +54,6 @@ public:
protected: protected:
explicit LocalApplicationRunConfiguration(Target *target, Core::Id id); explicit LocalApplicationRunConfiguration(Target *target, Core::Id id);
explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc); explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc);
private:
void setupMacroExpander();
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -254,7 +254,13 @@ void RunConfiguration::ctor()
{ {
connect(this, SIGNAL(enabledChanged()), this, SIGNAL(requestRunActionsUpdate())); 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();
});
} }
/*! /*!

View File

@@ -140,27 +140,20 @@ Target::Target(Project *project, Kit *k) :
this, SLOT(handleKitRemoval(ProjectExplorer::Kit*))); this, SLOT(handleKitRemoval(ProjectExplorer::Kit*)));
Utils::MacroExpander *expander = macroExpander(); Utils::MacroExpander *expander = macroExpander();
expander->setDisplayName(tr("Target Settings"));
expander->setAccumulating(true);
expander->registerSubProvider([this] { return kit()->macroExpander(); }); expander->registerSubProvider([this] { return kit()->macroExpander(); });
expander->registerVariable("sourceDir", tr("Source directory"),
[project] { return project->projectDirectory().toUserOutput(); });
// Legacy support. // Legacy support.
expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME, expander->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);
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() Target::~Target()