Commit 20214787 authored by dt's avatar dt

Add BuildConfiguration::restore and BuildConfiguration::project()

More API work.
parent ae633c19
......@@ -28,9 +28,13 @@
**************************************************************************/
#include "cmakebuildconfiguration.h"
#include "cmakeproject.h"
CMakeBuildConfiguration::CMakeBuildConfiguration(const QString &name)
: BuildConfiguration(name)
using namespace CMakeProjectManager;
using namespace Internal;
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro, const QString &name)
: BuildConfiguration(pro, name)
{
}
......@@ -40,3 +44,4 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(const QString &name, BuildConfi
{
}
......@@ -32,11 +32,20 @@
#include <projectexplorer/buildconfiguration.h>
namespace CMakeProjectManager {
namespace Internal {
class CMakeProject;
class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
CMakeBuildConfiguration(const QString &name);
CMakeBuildConfiguration(CMakeProject *pro, const QString &name);
CMakeBuildConfiguration(const QString &name, BuildConfiguration *source);
};
} // namespace Internal
} // namespace CMakeProjectManager
#endif // CMAKEBUILDCONFIGURATION_H
......@@ -90,7 +90,7 @@ QString CMakeBuildConfigurationFactory::displayNameForType(const QString & /* ty
return tr("Create");
}
bool CMakeBuildConfigurationFactory::create(const QString &type) const
BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &type) const
{
QTC_ASSERT(type == "Create", return false);
......@@ -104,7 +104,7 @@ bool CMakeBuildConfigurationFactory::create(const QString &type) const
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
BuildConfiguration *bc = new CMakeBuildConfiguration(buildConfigurationName);
BuildConfiguration *bc = new CMakeBuildConfiguration(m_project, buildConfigurationName);
MakeStep *makeStep = new MakeStep(m_project, bc);
bc->insertBuildStep(0, makeStep);
......@@ -130,15 +130,21 @@ bool CMakeBuildConfigurationFactory::create(const QString &type) const
// Default to all
if (m_project->targets().contains("all"))
makeStep->setBuildTarget("all", true);
return true;
return bc;
}
bool CMakeBuildConfigurationFactory::clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const
BuildConfiguration *CMakeBuildConfigurationFactory::clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const
{
CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(name, old);
m_project->addBuildConfiguration(bc);
return true;
return bc;
}
BuildConfiguration *CMakeBuildConfigurationFactory::restore(const QString &name) const
{
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project, name);
return bc;
}
/*!
......@@ -658,7 +664,7 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
if (copw.exec() != QDialog::Accepted)
return false;
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration("all");
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(this, "all");
addBuildConfiguration(bc);
bc->setValue("msvcVersion", copw.msvcVersion());
if (!copw.buildDirectory().isEmpty())
......@@ -677,8 +683,6 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
// We have a user file, but we could still be missing the cbp file
// or simply run createXml with the saved settings
QFileInfo sourceFileInfo(m_fileName);
QStringList needToCreate;
QStringList needToUpdate;
BuildConfiguration *activeBC = activeBuildConfiguration();
QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory(activeBC)));
QFileInfo cbpFileFi(cbpFile);
......
......@@ -73,8 +73,9 @@ public:
QStringList availableCreationTypes() const;
QString displayNameForType(const QString &type) const;
bool create(const QString &type) const;
bool clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *create(const QString &type) const;
ProjectExplorer::BuildConfiguration *clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *restore(const QString &name) const;
private:
CMakeProject *m_project;
......
......@@ -28,13 +28,14 @@
**************************************************************************/
#include "genericbuildconfiguration.h"
#include "genericproject.h"
using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
using ProjectExplorer::BuildConfiguration;
GenericBuildConfiguration::GenericBuildConfiguration(const QString &name)
: BuildConfiguration(name)
GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro, const QString &name)
: BuildConfiguration(pro, name)
{
}
......
......@@ -33,13 +33,15 @@
#include <projectexplorer/buildconfiguration.h>
namespace GenericProjectManager {
namespace Internal {
namespace Internal {
class GenericProject;
class GenericBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
GenericBuildConfiguration(const QString &name);
GenericBuildConfiguration(GenericProject *pro, const QString &name);
GenericBuildConfiguration(const QString &name, GenericBuildConfiguration *source);
};
......
......@@ -132,7 +132,7 @@ QString GenericBuildConfigurationFactory::displayNameForType(const QString & /*
return tr("Create");
}
bool GenericBuildConfigurationFactory::create(const QString &type) const
BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &type) const
{
QTC_ASSERT(type == "Create", return false);
//TODO asking for name is duplicated everywhere, but maybe more
......@@ -146,21 +146,27 @@ bool GenericBuildConfigurationFactory::create(const QString &type) const
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
GenericBuildConfiguration *bc = new GenericBuildConfiguration(buildConfigurationName);
GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project, buildConfigurationName);
m_project->addBuildConfiguration(bc); // also makes the name unique...
GenericMakeStep *makeStep = new GenericMakeStep(m_project, bc);
bc->insertBuildStep(0, makeStep);
makeStep->setBuildTarget("all", /* on = */ true);
return true;
return bc;
}
bool GenericBuildConfigurationFactory::clone(const QString &name, BuildConfiguration *source) const
BuildConfiguration *GenericBuildConfigurationFactory::clone(const QString &name, BuildConfiguration *source) const
{
// TODO
GenericBuildConfiguration *bc = new GenericBuildConfiguration(name, static_cast<GenericBuildConfiguration *>(source));
m_project->addBuildConfiguration(bc);
return true;
return bc;
}
BuildConfiguration *GenericBuildConfigurationFactory::restore(const QString &name) const
{
GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project, name);
return bc;
}
////////////////////////////////////////////////////////////////////////////////////
......@@ -527,7 +533,7 @@ bool GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
Project::restoreSettingsImpl(reader);
if (buildConfigurations().isEmpty()) {
GenericBuildConfiguration *bc = new GenericBuildConfiguration("all");
GenericBuildConfiguration *bc = new GenericBuildConfiguration(this, "all");
addBuildConfiguration(bc);
GenericMakeStep *makeStep = new GenericMakeStep(this, bc);
......
......@@ -66,8 +66,9 @@ public:
QStringList availableCreationTypes() const;
QString displayNameForType(const QString &type) const;
bool create(const QString &type) const;
bool clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *create(const QString &type) const;
ProjectExplorer::BuildConfiguration *clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *restore(const QString &name) const;
private:
GenericProject *m_project;
......
......@@ -44,14 +44,14 @@ IBuildStepFactory *findFactory(const QString &name)
return 0;
}
BuildConfiguration::BuildConfiguration(const QString &name)
: m_name(name)
BuildConfiguration::BuildConfiguration(Project *pro, const QString &name)
: m_name(name), m_project(pro)
{
setDisplayName(name);
}
BuildConfiguration::BuildConfiguration(const QString &name, BuildConfiguration *source)
: m_values(source->m_values), m_name(name)
: m_values(source->m_values), m_name(name), m_project(source->m_project)
{
foreach(BuildStep *originalbs, source->buildSteps()) {
IBuildStepFactory *factory = findFactory(originalbs->name());
......@@ -172,6 +172,11 @@ void BuildConfiguration::moveCleanStepUp(int position)
m_cleanSteps.swap(position - 1, position);
}
Project *BuildConfiguration::project() const
{
return m_project;
}
///
// IBuildConfigurationFactory
///
......
......@@ -74,8 +74,10 @@ public:
void removeCleanStep(int position);
void moveCleanStepUp(int position);
Project *project() const;
protected:
BuildConfiguration(const QString &name);
BuildConfiguration(Project * project, const QString &name);
BuildConfiguration(const QString &name, BuildConfiguration *source);
private:
......@@ -86,6 +88,7 @@ private:
QHash<QString, QVariant> m_values;
QString m_name;
Project *m_project;
friend class Project; // for setName
};
......@@ -104,15 +107,18 @@ public:
// creates build configuration(s) for given type and adds them to project
// returns true if build configuration(s) actually have been added
virtual bool create(const QString &type) const = 0;
virtual BuildConfiguration *create(const QString &type) const = 0;
// clones a given BuildConfiguration and adds it to the project
virtual BuildConfiguration *clone(const QString &name, BuildConfiguration *source) const = 0;
// restores a BuildConfiguration with the name and adds it to the project
virtual BuildConfiguration *restore(const QString &name) const = 0;
// clones a given BuildConfiguration
virtual bool clone(const QString &name, BuildConfiguration *source) const = 0;
// TODO All those methods make the internal name (and display name) unique,
// but in different ways
//virtual bool restore(const QString &name);
// to come:
// restore
......
......@@ -222,8 +222,8 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader)
// restoring BuldConfigurations from settings
const QStringList buildConfigurationNames = reader.restoreValue("buildconfigurations").toStringList();
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
BuildConfiguration *bc = new BuildConfiguration(buildConfigurationName);
addBuildConfiguration(bc);
BuildConfiguration *bc = buildConfigurationFactory()->restore(buildConfigurationName);
QMap<QString, QVariant> temp =
reader.restoreValue("buildConfiguration-" + buildConfigurationName).toMap();
bc->setValuesFromMap(temp);
......
......@@ -28,13 +28,14 @@
**************************************************************************/
#include "qt4buildconfiguration.h"
#include "qt4project.h"
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::BuildConfiguration;
Qt4BuildConfiguration::Qt4BuildConfiguration(const QString &name)
: BuildConfiguration(name)
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro, const QString &name)
: BuildConfiguration(pro, name)
{
}
......
......@@ -33,12 +33,15 @@
#include <projectexplorer/buildconfiguration.h>
namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class Qt4BuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
Qt4BuildConfiguration(const QString &name);
Qt4BuildConfiguration(Qt4Project *pro, const QString &name);
// copy ctor
Qt4BuildConfiguration(const QString &name, Qt4BuildConfiguration *source);
~Qt4BuildConfiguration();
......
......@@ -270,7 +270,7 @@ QString Qt4BuildConfigurationFactory::displayNameForType(const QString &type) co
return QString();
}
bool Qt4BuildConfigurationFactory::create(const QString &type) const
BuildConfiguration *Qt4BuildConfigurationFactory::create(const QString &type) const
{
QTC_ASSERT(m_versions.contains(type), return false);
const VersionInfo &info = m_versions.value(type);
......@@ -290,18 +290,25 @@ bool Qt4BuildConfigurationFactory::create(const QString &type) const
m_project->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName),
version,
(version->defaultBuildConfig() | QtVersion::DebugBuild));
BuildConfiguration *bc =
m_project->addQt4BuildConfiguration(tr("%1 Release").arg(buildConfigurationName),
version,
(version->defaultBuildConfig() & ~QtVersion::DebugBuild));
return true;
return bc;
}
bool Qt4BuildConfigurationFactory::clone(const QString &name, BuildConfiguration *source) const
BuildConfiguration *Qt4BuildConfigurationFactory::clone(const QString &name, BuildConfiguration *source) const
{
Qt4BuildConfiguration *oldbc = static_cast<Qt4BuildConfiguration *>(source);
Qt4BuildConfiguration *newbc = new Qt4BuildConfiguration(name, oldbc);
m_project->addBuildConfiguration(newbc);
return true;
return newbc;
}
BuildConfiguration *Qt4BuildConfigurationFactory::restore(const QString &name) const
{
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(m_project, name);
return bc;
}
/*!
......@@ -445,14 +452,14 @@ ProjectExplorer::IBuildConfigurationFactory *Qt4Project::buildConfigurationFacto
return m_buildConfigurationFactory;
}
void Qt4Project::addQt4BuildConfiguration(QString buildConfigurationName, QtVersion *qtversion,
Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString buildConfigurationName, QtVersion *qtversion,
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
QStringList additionalArguments)
{
bool debug = qmakeBuildConfiguration & QtVersion::DebugBuild;
// Add the buildconfiguration
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(buildConfigurationName);
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(this, buildConfigurationName);
addBuildConfiguration(bc);
QMakeStep *qmakeStep = new QMakeStep(this, bc);
......@@ -479,6 +486,7 @@ void Qt4Project::addQt4BuildConfiguration(QString buildConfigurationName, QtVers
setQtVersion(bc, 0);
else
setQtVersion(bc, qtversion->uniqueId());
return bc;
}
namespace {
......
......@@ -73,6 +73,7 @@ namespace Internal {
class GCCPreprocessor;
struct Qt4ProjectFiles;
class Qt4ProjectConfigWidget;
class Qt4BuildConfiguration;
class CodeModelInfo
{
......@@ -130,8 +131,9 @@ public:
QStringList availableCreationTypes() const;
QString displayNameForType(const QString &type) const;
bool create(const QString &type) const;
bool clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *create(const QString &type) const;
ProjectExplorer::BuildConfiguration *clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *restore(const QString &name) const;
void update();
......@@ -162,10 +164,10 @@ public:
Qt4Manager *qt4ProjectManager() const;
ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const;
void addQt4BuildConfiguration(QString buildConfigurationName,
QtVersion *qtversion,
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
QStringList additionalArguments = QStringList());
Internal::Qt4BuildConfiguration *addQt4BuildConfiguration(QString buildConfigurationName,
QtVersion *qtversion,
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
QStringList additionalArguments = QStringList());
QList<Core::IFile *> dependencies(); //NBS remove
QList<ProjectExplorer::Project *>dependsOn();
......
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