summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/buildconfiguration.cpp
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-10-22 18:16:51 +0200
committerhjk <hjk121@nokiamail.com>2014-10-23 12:59:02 +0200
commit8eb08db536f7e06df364689b963be105ce57b7ac (patch)
tree7cc9bd4d4ef8b71a402cb4364ea2d16a418ccfa9 /src/plugins/projectexplorer/buildconfiguration.cpp
parent3ce62fc59e8fdda33e254d57fdd39480c77097dd (diff)
downloadqt-creator-8eb08db536f7e06df364689b963be105ce57b7ac.tar.gz
Add MacroExpander member to ProjectConfiguration
Some derived classes already had one, at times. Make it uniformly accessible in the base class. Change-Id: Iccb7ebf9d163daba46a01ae5de150af4a883fad6 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/projectexplorer/buildconfiguration.cpp')
-rw-r--r--src/plugins/projectexplorer/buildconfiguration.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp
index b48d21e7b3..7ae211d4a7 100644
--- a/src/plugins/projectexplorer/buildconfiguration.cpp
+++ b/src/plugins/projectexplorer/buildconfiguration.cpp
@@ -58,8 +58,7 @@ namespace ProjectExplorer {
BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) :
ProjectConfiguration(target, id),
- m_clearSystemEnvironment(false),
- m_macroExpander(0)
+ m_clearSystemEnvironment(false)
{
Q_ASSERT(target);
BuildStepList *bsl = new BuildStepList(this, Core::Id(Constants::BUILDSTEPS_BUILD));
@@ -82,7 +81,6 @@ BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *sourc
ProjectConfiguration(target, source),
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
- m_macroExpander(0),
m_buildDirectory(source->m_buildDirectory)
{
Q_ASSERT(target);
@@ -96,9 +94,31 @@ BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *sourc
this, SLOT(handleKitUpdate()));
}
+void BuildConfiguration::setupMacroExpander()
+{
+ Utils::MacroExpander *expander = macroExpander();
+
+ expander->registerSubProvider(
+ [this] { return target()->kit()->macroExpander(); });
+
+ // Legacy support.
+ expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
+ QCoreApplication::translate("ProjectExplorer", "Name of current project"),
+ [this] { return target()->project()->displayName(); });
+
+ expander->registerVariable(Constants::VAR_CURRENTBUILD_NAME,
+ QCoreApplication::translate("ProjectExplorer", "Name of current build"),
+ [this] { return displayName(); });
+
+ expander->registerVariable("sourceDir", tr("Source directory"),
+ [this] { return target()->project()->projectDirectory().toUserOutput(); });
+
+ expander->registerVariable("buildDir", tr("Build directory"),
+ [this] { return buildDirectory().toUserOutput(); });
+}
+
BuildConfiguration::~BuildConfiguration()
{
- delete m_macroExpander;
}
Utils::FileName BuildConfiguration::buildDirectory() const
@@ -123,26 +143,6 @@ QList<NamedWidget *> BuildConfiguration::createSubConfigWidgets()
return QList<NamedWidget *>() << new BuildEnvironmentWidget(this);
}
-Utils::MacroExpander *BuildConfiguration::macroExpander()
-{
- if (!m_macroExpander) {
- m_macroExpander = new ProjectMacroExpander(target()->project()->displayName(),
- target()->kit(), displayName());
-
- m_macroExpander->registerSubProvider(
- [this]() { return target()->kit()->macroExpander(); });
-
- // Legacy support.
- m_macroExpander->registerVariable("sourceDir", tr("Source directory"),
- [this]() { return target()->project()->projectDirectory().toUserOutput(); });
-
- m_macroExpander->registerVariable("buildDir", tr("Build directory"),
- [this]() { return buildDirectory().toUserOutput(); });
- }
-
- return m_macroExpander;
-}
-
QList<Core::Id> BuildConfiguration::knownStepLists() const
{
return Utils::transform(m_stepLists, &BuildStepList::id);