Move uses of ProjectMacroExpander closer to build configuration

All static functions, can live closer to related code.

Change-Id: I54c5680256c78f1d09b4bee3e8843b2f4350b75a
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2014-10-22 09:16:55 +02:00
parent 5003bc60d0
commit edc08ba2bc
16 changed files with 108 additions and 129 deletions

View File

@@ -35,31 +35,48 @@
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmacroexpander.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <QInputDialog>
using namespace CMakeProjectManager;
using namespace Internal;
using namespace ProjectExplorer;
using namespace Utils;
namespace CMakeProjectManager {
namespace Internal {
namespace {
const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNinja";
} // namespace
static QString shadowBuildDirectory(const QString &projectFilePath, const Kit *k, const QString &bcName)
{
if (projectFilePath.isEmpty())
return QString();
QFileInfo info(projectFilePath);
const QString projectName = QFileInfo(info.absolutePath()).fileName();
ProjectMacroExpander expander(projectName, k, bcName);
QDir projectDir = QDir(Project::projectDirectory(FileName::fromString(projectFilePath)).toString());
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return QDir::cleanPath(projectDir.absoluteFilePath(buildPath));
}
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) :
BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)), m_useNinja(false)
{
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
setBuildDirectory(Utils::FileName::fromString(project->shadowBuildDirectory(project->projectFilePath().toString(),
parent->kit(),
displayName())));
setBuildDirectory(Utils::FileName::fromString(shadowBuildDirectory(project->projectFilePath().toString(),
parent->kit(),
displayName())));
}
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent,
@@ -156,9 +173,7 @@ QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableSet
CMakeBuildInfo *info = createBuildInfo(k, ProjectExplorer::Project::projectDirectory(Utils::FileName::fromString(projectPath)).toString());
//: The name of the build configuration created by default for a cmake project.
info->displayName = tr("Default");
info->buildDirectory
= Utils::FileName::fromString(CMakeProject::shadowBuildDirectory(projectPath, k,
info->displayName));
info->buildDirectory = FileName::fromString(shadowBuildDirectory(projectPath, k, info->displayName));
result << info;
return result;
}
@@ -174,10 +189,9 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
if (copy.buildDirectory.isEmpty())
copy.buildDirectory
= Utils::FileName::fromString(project->shadowBuildDirectory(project->projectFilePath().toString(),
parent->kit(),
copy.displayName));
copy.buildDirectory = FileName::fromString(shadowBuildDirectory(project->projectFilePath().toString(),
parent->kit(),
copy.displayName));
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, &copy);
if (copw.exec() != QDialog::Accepted)
@@ -295,3 +309,5 @@ ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildTyp
return Unknown;
}
} // namespace Internal
} // namespace CMakeProjectManager