Commit b94a6a05 authored by hjk's avatar hjk
Browse files

Set up hierarchy of ProjectConfiguration macro expanders.



BuildConfiguration asks Target,
Deploy and Run ask either activeBuild, or Target.

Change-Id: I3845cfbd16de7b85268d83b5324865ff24482152
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent d8edeb1e
......@@ -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()
......
......@@ -107,6 +107,7 @@ private slots:
private:
void emitEnvironmentChanged();
void ctor();
bool m_clearSystemEnvironment;
QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
......
......@@ -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()
......
......@@ -76,6 +76,8 @@ protected:
void cloneSteps(DeployConfiguration *source);
private:
void ctor();
BuildStepList *m_stepList;
};
......
......@@ -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
......@@ -54,9 +54,6 @@ public:
protected:
explicit LocalApplicationRunConfiguration(Target *target, Core::Id id);
explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc);
private:
void setupMacroExpander();
};
} // namespace ProjectExplorer
......
......@@ -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();
});
}
/*!
......
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment