forked from qt-creator/qt-creator
BuildConfigurationFactory: Refactor code
Refactor the code of the build configuration factories. The idea is to generalize the code so much that we can allow plugins to install custom build configuration factories for the platforms they support. To support this use case the following changes where done here: * BuildInfo class was introduced to describe one build configuration that can be created by a factory. * Factories report a list of BuildInfo to describe what they can produce. This fixes the need for factories to implicitly create one buildconfiguration and then create another one 'officially' to support debug and release build configurations to be set up for projects. * Do no longer work around factories to create build configurations. Change-Id: Ic372e4a9b5c582633b467d130538948472b89d91 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -38,6 +38,9 @@
|
||||
#include "autoreconfstep.h"
|
||||
#include "configurestep.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -46,6 +49,7 @@
|
||||
#include <qtsupport/customexecutablerunconfiguration.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QInputDialog>
|
||||
|
||||
using namespace AutotoolsProjectManager;
|
||||
@@ -85,59 +89,38 @@ AutotoolsBuildConfigurationFactory::AutotoolsBuildConfigurationFactory(QObject *
|
||||
{
|
||||
}
|
||||
|
||||
QList<Core::Id> AutotoolsBuildConfigurationFactory::availableCreationIds(const Target *parent) const
|
||||
bool AutotoolsBuildConfigurationFactory::canCreate(const Target *parent) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
return QList<Core::Id>() << Core::Id(AUTOTOOLS_BC_ID);
|
||||
return canHandle(parent);
|
||||
}
|
||||
|
||||
QString AutotoolsBuildConfigurationFactory::displayNameForId(const Core::Id id) const
|
||||
QList<BuildInfo *> AutotoolsBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
||||
{
|
||||
if (id == AUTOTOOLS_BC_ID)
|
||||
return tr("Build");
|
||||
return QString();
|
||||
QList<BuildInfo *> result;
|
||||
QTC_ASSERT(canCreate(parent), return result);
|
||||
|
||||
result << createBuildInfo(parent->kit(),
|
||||
Utils::FileName::fromString(parent->project()->projectDirectory()));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AutotoolsBuildConfigurationFactory::canCreate(const Target *parent, const Core::Id id) const
|
||||
BuildConfiguration *AutotoolsBuildConfigurationFactory::create(Target *parent, const BuildInfo *info) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
if (id == AUTOTOOLS_BC_ID)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
QTC_ASSERT(parent, return 0);
|
||||
QTC_ASSERT(info->factory() == this, return 0);
|
||||
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
||||
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
||||
|
||||
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::create(Target *parent, const Core::Id id, const QString &name)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
AutotoolsBuildConfiguration *bc = new AutotoolsBuildConfiguration(parent);
|
||||
bc->setDisplayName(info->displayName);
|
||||
bc->setDefaultDisplayName(info->displayName);
|
||||
bc->setBuildDirectory(info->buildDirectory);
|
||||
|
||||
bool ok = true;
|
||||
QString buildConfigurationName = name;
|
||||
if (buildConfigurationName.isNull())
|
||||
buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New Configuration"),
|
||||
tr("New configuration name:"),
|
||||
QLineEdit::Normal,
|
||||
QString(), &ok);
|
||||
buildConfigurationName = buildConfigurationName.trimmed();
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return 0;
|
||||
|
||||
AutotoolsBuildConfiguration *bc = createDefaultConfiguration(parent);
|
||||
bc->setDisplayName(buildConfigurationName);
|
||||
return bc;
|
||||
}
|
||||
|
||||
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::createDefaultConfiguration(ProjectExplorer::Target *target)
|
||||
{
|
||||
AutotoolsBuildConfiguration *bc = new AutotoolsBuildConfiguration(target);
|
||||
BuildStepList *buildSteps = bc->stepList(Core::Id(BUILDSTEPS_BUILD));
|
||||
|
||||
// ### Build Steps Build ###
|
||||
// autogen.sh or autoreconf
|
||||
QFile autogenFile(target->project()->projectDirectory() + QLatin1String("/autogen.sh"));
|
||||
QFile autogenFile(parent->project()->projectDirectory() + QLatin1String("/autogen.sh"));
|
||||
if (autogenFile.exists()) {
|
||||
AutogenStep *autogenStep = new AutogenStep(buildSteps);
|
||||
buildSteps->insertStep(0, autogenStep);
|
||||
@@ -168,14 +151,29 @@ AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::createDefaultCo
|
||||
|
||||
bool AutotoolsBuildConfigurationFactory::canHandle(const Target *t) const
|
||||
{
|
||||
QTC_ASSERT(t, return false);
|
||||
|
||||
if (!t->project()->supportsKit(t->kit()))
|
||||
return false;
|
||||
return t->project()->id() == Constants::AUTOTOOLS_PROJECT_ID;
|
||||
}
|
||||
|
||||
BuildInfo *AutotoolsBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k,
|
||||
const Utils::FileName &buildDir) const
|
||||
{
|
||||
BuildInfo *info = new BuildInfo(this);
|
||||
info->typeName = tr("Build");
|
||||
info->buildDirectory = buildDir;
|
||||
info->kitId = k->id();
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
bool AutotoolsBuildConfigurationFactory::canClone(const Target *parent, BuildConfiguration *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return source->id() == AUTOTOOLS_BC_ID;
|
||||
}
|
||||
|
||||
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::clone(Target *parent, BuildConfiguration *source)
|
||||
@@ -189,7 +187,9 @@ AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::clone(Target *p
|
||||
|
||||
bool AutotoolsBuildConfigurationFactory::canRestore(const Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, idFromMap(map));
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return idFromMap(map) == AUTOTOOLS_BC_ID;
|
||||
}
|
||||
|
||||
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
||||
|
@@ -34,6 +34,8 @@
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
|
||||
namespace Utils { class FileName; }
|
||||
|
||||
namespace AutotoolsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -67,20 +69,19 @@ class AutotoolsBuildConfigurationFactory : public ProjectExplorer::IBuildConfigu
|
||||
public:
|
||||
explicit AutotoolsBuildConfigurationFactory(QObject *parent = 0);
|
||||
|
||||
QList<Core::Id> availableCreationIds(const ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const Core::Id id) const;
|
||||
bool canCreate(const ProjectExplorer::Target *parent) const;
|
||||
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent,
|
||||
const ProjectExplorer::BuildInfo *info) const;
|
||||
|
||||
bool canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
AutotoolsBuildConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name = QString());
|
||||
bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const;
|
||||
AutotoolsBuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source);
|
||||
bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
AutotoolsBuildConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
|
||||
|
||||
static AutotoolsBuildConfiguration *createDefaultConfiguration(ProjectExplorer::Target *target);
|
||||
|
||||
private:
|
||||
bool canHandle(const ProjectExplorer::Target *t) const;
|
||||
ProjectExplorer::BuildInfo *createBuildInfo(const ProjectExplorer::Kit *k, const Utils::FileName &buildDir) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -34,6 +34,8 @@
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QDir)
|
||||
|
||||
namespace Utils {
|
||||
|
@@ -29,15 +29,20 @@
|
||||
|
||||
#include "cmakebuildconfiguration.h"
|
||||
|
||||
#include "cmakebuildinfo.h"
|
||||
#include "cmakeopenprojectwizard.h"
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
@@ -117,64 +122,45 @@ CMakeBuildConfigurationFactory::~CMakeBuildConfigurationFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QList<Core::Id> CMakeBuildConfigurationFactory::availableCreationIds(const ProjectExplorer::Target *parent) const
|
||||
bool CMakeBuildConfigurationFactory::canCreate(const ProjectExplorer::Target *parent) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
return QList<Core::Id>() << Core::Id(Constants::CMAKE_BC_ID);
|
||||
return canHandle(parent);
|
||||
}
|
||||
|
||||
QString CMakeBuildConfigurationFactory::displayNameForId(const Core::Id id) const
|
||||
QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableBuilds(const ProjectExplorer::Target *parent) const
|
||||
{
|
||||
if (id == Constants::CMAKE_BC_ID)
|
||||
return tr("Build");
|
||||
return QString();
|
||||
QList<ProjectExplorer::BuildInfo *> result;
|
||||
QTC_ASSERT(canCreate(parent), return result);
|
||||
|
||||
CMakeBuildInfo *info = createBuildInfo(parent->kit(), parent->project()->projectDirectory());
|
||||
result << info;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CMakeBuildConfigurationFactory::canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const
|
||||
ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer::Target *parent,
|
||||
const ProjectExplorer::BuildInfo *info) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
if (id == Constants::CMAKE_BC_ID)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
QTC_ASSERT(canCreate(parent), return 0);
|
||||
QTC_ASSERT(info->factory() == this, return 0);
|
||||
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
||||
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
||||
|
||||
CMakeBuildInfo copy(*static_cast<const CMakeBuildInfo *>(info));
|
||||
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
||||
|
||||
bool ok = true;
|
||||
QString buildConfigurationName = name;
|
||||
if (buildConfigurationName.isNull())
|
||||
buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New Configuration"),
|
||||
tr("New configuration name:"),
|
||||
QLineEdit::Normal,
|
||||
QString(), &ok);
|
||||
buildConfigurationName = buildConfigurationName.trimmed();
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return 0;
|
||||
if (copy.buildDirectory.isEmpty())
|
||||
copy.buildDirectory
|
||||
= Utils::FileName::fromString(project->shadowBuildDirectory(project->projectFilePath(),
|
||||
parent->kit(),
|
||||
copy.displayName));
|
||||
|
||||
CMakeOpenProjectWizard::BuildInfo info;
|
||||
info.sourceDirectory = project->projectDirectory();
|
||||
info.environment = Utils::Environment::systemEnvironment();
|
||||
parent->kit()->addToEnvironment(info.environment);
|
||||
info.buildDirectory = project->shadowBuildDirectory(project->projectFilePath(),
|
||||
parent->kit(),
|
||||
buildConfigurationName);
|
||||
info.kit = parent->kit();
|
||||
info.useNinja = false; // This is ignored anyway
|
||||
|
||||
CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, info);
|
||||
CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, ©);
|
||||
if (copw.exec() != QDialog::Accepted)
|
||||
return 0;
|
||||
|
||||
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(parent);
|
||||
bc->setDisplayName(buildConfigurationName);
|
||||
bc->setDisplayName(copy.displayName);
|
||||
bc->setDefaultDisplayName(copy.displayName);
|
||||
|
||||
ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
|
||||
@@ -199,7 +185,9 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer:
|
||||
|
||||
bool CMakeBuildConfigurationFactory::canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return source->id() == Constants::CMAKE_BC_ID;
|
||||
}
|
||||
|
||||
CMakeBuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source)
|
||||
@@ -212,7 +200,9 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::
|
||||
|
||||
bool CMakeBuildConfigurationFactory::canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return ProjectExplorer::idFromMap(map) == Constants::CMAKE_BC_ID;
|
||||
}
|
||||
|
||||
CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
@@ -228,11 +218,26 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer
|
||||
|
||||
bool CMakeBuildConfigurationFactory::canHandle(const ProjectExplorer::Target *t) const
|
||||
{
|
||||
QTC_ASSERT(t, return false);
|
||||
if (!t->project()->supportsKit(t->kit()))
|
||||
return false;
|
||||
return qobject_cast<CMakeProject *>(t->project());
|
||||
}
|
||||
|
||||
CMakeBuildInfo *CMakeBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k,
|
||||
const QString &sourceDir) const
|
||||
{
|
||||
CMakeBuildInfo *info = new CMakeBuildInfo(this);
|
||||
info->typeName = tr("Build");
|
||||
info->kitId = k->id();
|
||||
info->environment = Utils::Environment::systemEnvironment();
|
||||
k->addToEnvironment(info->environment);
|
||||
info->useNinja = false;
|
||||
info->sourceDirectory = sourceDir;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const
|
||||
{
|
||||
QString cmakeBuildType;
|
||||
|
@@ -38,6 +38,8 @@ class ToolChain;
|
||||
}
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
class CMakeBuildInfo;
|
||||
|
||||
namespace Internal {
|
||||
class CMakeProject;
|
||||
|
||||
@@ -83,11 +85,11 @@ public:
|
||||
CMakeBuildConfigurationFactory(QObject *parent = 0);
|
||||
~CMakeBuildConfigurationFactory();
|
||||
|
||||
QList<Core::Id> availableCreationIds(const ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const Core::Id id) const;
|
||||
bool canCreate(const ProjectExplorer::Target *parent) const;
|
||||
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent,
|
||||
const ProjectExplorer::BuildInfo *info) const;
|
||||
|
||||
bool canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
CMakeBuildConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name = QString());
|
||||
bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const;
|
||||
CMakeBuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source);
|
||||
bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
@@ -95,6 +97,7 @@ public:
|
||||
|
||||
private:
|
||||
bool canHandle(const ProjectExplorer::Target *t) const;
|
||||
CMakeBuildInfo *createBuildInfo(const ProjectExplorer::Kit *k, const QString &sourceDir) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
65
src/plugins/cmakeprojectmanager/cmakebuildinfo.h
Normal file
65
src/plugins/cmakeprojectmanager/cmakebuildinfo.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CMAKEBUILDINFO_H
|
||||
#define CMAKEBUILDINFO_H
|
||||
|
||||
#include "cmakebuildconfiguration.h"
|
||||
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <utils/environment.h>
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
|
||||
class CMakeBuildInfo : public ProjectExplorer::BuildInfo
|
||||
{
|
||||
public:
|
||||
CMakeBuildInfo(const ProjectExplorer::IBuildConfigurationFactory *f) :
|
||||
ProjectExplorer::BuildInfo(f) { }
|
||||
|
||||
CMakeBuildInfo(const Internal::CMakeBuildConfiguration *bc) :
|
||||
ProjectExplorer::BuildInfo(ProjectExplorer::IBuildConfigurationFactory::find(bc->target()))
|
||||
{
|
||||
displayName = bc->displayName();
|
||||
buildDirectory = bc->buildDirectory();
|
||||
kitId = bc->target()->kit()->id();
|
||||
environment = bc->environment();
|
||||
useNinja = bc->useNinja();
|
||||
}
|
||||
|
||||
Utils::Environment environment;
|
||||
QString sourceDirectory;
|
||||
bool useNinja;
|
||||
};
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
#endif // CMAKEBUILDINFO_H
|
@@ -30,6 +30,7 @@
|
||||
#include "cmakeopenprojectwizard.h"
|
||||
#include "cmakeprojectmanager.h"
|
||||
#include "cmakebuildconfiguration.h"
|
||||
#include "cmakebuildinfo.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
@@ -240,13 +241,15 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
|
||||
}
|
||||
|
||||
CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, CMakeOpenProjectWizard::Mode mode,
|
||||
const BuildInfo &info)
|
||||
const CMakeBuildInfo *info)
|
||||
: m_cmakeManager(cmakeManager),
|
||||
m_sourceDirectory(info.sourceDirectory),
|
||||
m_environment(info.environment),
|
||||
m_useNinja(info.useNinja),
|
||||
m_kit(info.kit)
|
||||
m_sourceDirectory(info->sourceDirectory),
|
||||
m_environment(info->environment),
|
||||
m_useNinja(info->useNinja),
|
||||
m_kit(0)
|
||||
{
|
||||
m_kit = ProjectExplorer::KitManager::find(info->kitId);
|
||||
|
||||
CMakeRunPage::Mode rmode;
|
||||
if (mode == CMakeOpenProjectWizard::NeedToCreate)
|
||||
rmode = CMakeRunPage::Recreate;
|
||||
@@ -258,13 +261,13 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, CMake
|
||||
rmode = CMakeRunPage::ChangeDirectory;
|
||||
|
||||
if (mode == CMakeOpenProjectWizard::ChangeDirectory) {
|
||||
m_buildDirectory = info.buildDirectory;
|
||||
m_buildDirectory = info->buildDirectory.toString();
|
||||
addPage(new ShadowBuildPage(this, true));
|
||||
}
|
||||
if (!m_cmakeManager->isCMakeExecutableValid())
|
||||
addPage(new ChooseCMakePage(this));
|
||||
|
||||
addPage(new CMakeRunPage(this, rmode, info.buildDirectory));
|
||||
addPage(new CMakeRunPage(this, rmode, info->buildDirectory.toString()));
|
||||
init();
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#define CMAKEOPENPROJECTWIZARD_H
|
||||
|
||||
#include "cmakebuildconfiguration.h"
|
||||
#include "cmakebuildinfo.h"
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/wizard.h>
|
||||
@@ -70,34 +71,13 @@ public:
|
||||
ChangeDirectory
|
||||
};
|
||||
|
||||
class BuildInfo
|
||||
{
|
||||
public:
|
||||
BuildInfo()
|
||||
{}
|
||||
|
||||
BuildInfo(CMakeBuildConfiguration *bc)
|
||||
: sourceDirectory(bc->target()->project()->projectDirectory())
|
||||
, buildDirectory(bc->buildDirectory().toString())
|
||||
, environment(bc->environment())
|
||||
, useNinja(bc->useNinja())
|
||||
, kit(bc->target()->kit())
|
||||
{}
|
||||
|
||||
QString sourceDirectory;
|
||||
QString buildDirectory;
|
||||
Utils::Environment environment;
|
||||
bool useNinja;
|
||||
ProjectExplorer::Kit *kit;
|
||||
};
|
||||
|
||||
/// used at importing a project without a .user file
|
||||
CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, Utils::Environment env);
|
||||
|
||||
/// used to update if we have already a .user file
|
||||
/// recreates or updates the cbp file
|
||||
/// Also used to change the build directory of one buildconfiguration or create a new buildconfiguration
|
||||
CMakeOpenProjectWizard(CMakeManager *cmakeManager, Mode mode, const BuildInfo &info);
|
||||
CMakeOpenProjectWizard(CMakeManager *cmakeManager, Mode mode, const CMakeBuildInfo *info);
|
||||
|
||||
QString buildDirectory() const;
|
||||
QString sourceDirectory() const;
|
||||
|
@@ -141,8 +141,8 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur
|
||||
}
|
||||
|
||||
if (mode != CMakeOpenProjectWizard::Nothing) {
|
||||
CMakeOpenProjectWizard copw(m_manager, mode,
|
||||
CMakeOpenProjectWizard::BuildInfo(cmakebc));
|
||||
CMakeBuildInfo info(cmakebc);
|
||||
CMakeOpenProjectWizard copw(m_manager, mode, &info);
|
||||
if (copw.exec() == QDialog::Accepted)
|
||||
cmakebc->setUseNinja(copw.useNinja()); // NeedToCreate can change the Ninja setting
|
||||
}
|
||||
@@ -585,8 +585,8 @@ bool CMakeProject::fromMap(const QVariantMap &map)
|
||||
mode = CMakeOpenProjectWizard::NeedToUpdate;
|
||||
|
||||
if (mode != CMakeOpenProjectWizard::Nothing) {
|
||||
CMakeOpenProjectWizard copw(m_manager, mode,
|
||||
CMakeOpenProjectWizard::BuildInfo(activeBC));
|
||||
CMakeBuildInfo info(activeBC);
|
||||
CMakeOpenProjectWizard copw(m_manager, mode, &info);
|
||||
if (copw.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
else
|
||||
@@ -867,8 +867,9 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
||||
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
|
||||
{
|
||||
CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
|
||||
CMakeBuildInfo info(m_buildConfiguration);
|
||||
CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory,
|
||||
CMakeOpenProjectWizard::BuildInfo(m_buildConfiguration));
|
||||
&info);
|
||||
if (copw.exec() == QDialog::Accepted) {
|
||||
project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
|
||||
m_buildConfiguration->setUseNinja(copw.useNinja());
|
||||
@@ -881,9 +882,9 @@ void CMakeBuildSettingsWidget::runCMake()
|
||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->saveModifiedFiles())
|
||||
return;
|
||||
CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
|
||||
CMakeBuildInfo info(m_buildConfiguration);
|
||||
CMakeOpenProjectWizard copw(project->projectManager(),
|
||||
CMakeOpenProjectWizard::WantToUpdate,
|
||||
CMakeOpenProjectWizard::BuildInfo(m_buildConfiguration));
|
||||
CMakeOpenProjectWizard::WantToUpdate, &info);
|
||||
if (copw.exec() == QDialog::Accepted)
|
||||
project->parseCMakeLists();
|
||||
}
|
||||
|
@@ -121,8 +121,9 @@ void CMakeManager::runCMake(ProjectExplorer::Project *project)
|
||||
CMakeBuildConfiguration *bc
|
||||
= static_cast<CMakeBuildConfiguration *>(cmakeProject->activeTarget()->activeBuildConfiguration());
|
||||
|
||||
CMakeOpenProjectWizard copw(this, CMakeOpenProjectWizard::WantToUpdate,
|
||||
CMakeOpenProjectWizard::BuildInfo(bc));
|
||||
CMakeBuildInfo info(bc);
|
||||
|
||||
CMakeOpenProjectWizard copw(this, CMakeOpenProjectWizard::WantToUpdate, &info);
|
||||
if (copw.exec() == QDialog::Accepted)
|
||||
cmakeProject->parseCMakeLists();
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
include(../../qtcreatorplugin.pri)
|
||||
|
||||
HEADERS = cmakeproject.h \
|
||||
HEADERS = cmakebuildinfo.h \
|
||||
cmakeproject.h \
|
||||
cmakeprojectplugin.h \
|
||||
cmakeprojectmanager.h \
|
||||
cmakeprojectconstants.h \
|
||||
|
@@ -22,6 +22,7 @@ QtcPlugin {
|
||||
"CMakeProjectManager.mimetypes.xml",
|
||||
"cmakebuildconfiguration.cpp",
|
||||
"cmakebuildconfiguration.h",
|
||||
"cmakebuildinfo.h",
|
||||
"cmakeeditor.cpp",
|
||||
"cmakeeditor.h",
|
||||
"cmakeeditorfactory.cpp",
|
||||
|
@@ -31,7 +31,11 @@
|
||||
|
||||
#include "genericmakestep.h"
|
||||
#include "genericproject.h"
|
||||
#include "genericprojectconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -83,53 +87,35 @@ GenericBuildConfigurationFactory::~GenericBuildConfigurationFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QList<Core::Id> GenericBuildConfigurationFactory::availableCreationIds(const Target *parent) const
|
||||
bool GenericBuildConfigurationFactory::canCreate(const Target *parent) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
return QList<Core::Id>() << Core::Id(GENERIC_BC_ID);
|
||||
return canHandle(parent);
|
||||
}
|
||||
|
||||
QString GenericBuildConfigurationFactory::displayNameForId(const Core::Id id) const
|
||||
QList<BuildInfo *> GenericBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
||||
{
|
||||
if (id == GENERIC_BC_ID)
|
||||
return tr("Build");
|
||||
return QString();
|
||||
QList<ProjectExplorer::BuildInfo *> result;
|
||||
QTC_ASSERT(canCreate(parent), return result);
|
||||
|
||||
BuildInfo *info = createBuildInfo(parent->kit(), Utils::FileName::fromString(parent->project()->projectDirectory()));
|
||||
result << info;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GenericBuildConfigurationFactory::canCreate(const Target *parent, const Core::Id id) const
|
||||
BuildConfiguration *GenericBuildConfigurationFactory::create(Target *parent, const BuildInfo *info) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
if (id == GENERIC_BC_ID)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BuildConfiguration *GenericBuildConfigurationFactory::create(Target *parent, const Core::Id id, const QString &name)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
|
||||
//TODO asking for name is duplicated everywhere, but maybe more
|
||||
// wizards will show up, that incorporate choosing the nam
|
||||
bool ok = true;
|
||||
QString buildConfigurationName = name;
|
||||
if (buildConfigurationName.isNull())
|
||||
buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New Configuration"),
|
||||
tr("New configuration name:"),
|
||||
QLineEdit::Normal,
|
||||
QString(), &ok);
|
||||
buildConfigurationName = buildConfigurationName.trimmed();
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return 0;
|
||||
QTC_ASSERT(canCreate(parent), return 0);
|
||||
QTC_ASSERT(info->factory() == this, return 0);
|
||||
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
||||
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
||||
|
||||
GenericBuildConfiguration *bc = new GenericBuildConfiguration(parent);
|
||||
bc->setDisplayName(buildConfigurationName);
|
||||
bc->setDisplayName(info->displayName);
|
||||
bc->setDefaultDisplayName(info->displayName);
|
||||
bc->setBuildDirectory(info->buildDirectory);
|
||||
|
||||
BuildStepList *buildSteps = bc->stepList(Constants::BUILDSTEPS_BUILD);
|
||||
BuildStepList *cleanSteps = bc->stepList(Constants::BUILDSTEPS_CLEAN);
|
||||
BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
|
||||
|
||||
Q_ASSERT(buildSteps);
|
||||
GenericMakeStep *makeStep = new GenericMakeStep(buildSteps);
|
||||
@@ -147,7 +133,9 @@ BuildConfiguration *GenericBuildConfigurationFactory::create(Target *parent, con
|
||||
|
||||
bool GenericBuildConfigurationFactory::canClone(const Target *parent, BuildConfiguration *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return source->id() == GENERIC_BC_ID;
|
||||
}
|
||||
|
||||
BuildConfiguration *GenericBuildConfigurationFactory::clone(Target *parent, BuildConfiguration *source)
|
||||
@@ -159,7 +147,9 @@ BuildConfiguration *GenericBuildConfigurationFactory::clone(Target *parent, Buil
|
||||
|
||||
bool GenericBuildConfigurationFactory::canRestore(const Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return ProjectExplorer::idFromMap(map) == GENERIC_BC_ID;
|
||||
}
|
||||
|
||||
BuildConfiguration *GenericBuildConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
||||
@@ -180,6 +170,16 @@ bool GenericBuildConfigurationFactory::canHandle(const Target *t) const
|
||||
return qobject_cast<GenericProject *>(t->project());
|
||||
}
|
||||
|
||||
BuildInfo *GenericBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k,
|
||||
const Utils::FileName &buildDir) const
|
||||
{
|
||||
BuildInfo *info = new BuildInfo(this);
|
||||
info->typeName = tr("Build");
|
||||
info->buildDirectory = buildDir;
|
||||
info->kitId = k->id();
|
||||
return info;
|
||||
}
|
||||
|
||||
BuildConfiguration::BuildType GenericBuildConfiguration::buildType() const
|
||||
{
|
||||
return Unknown;
|
||||
|
@@ -33,7 +33,10 @@
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/namedwidget.h>
|
||||
|
||||
namespace Utils { class PathChooser; }
|
||||
namespace Utils {
|
||||
class FileName;
|
||||
class PathChooser;
|
||||
} // namespace Utils
|
||||
|
||||
namespace GenericProjectManager {
|
||||
namespace Internal {
|
||||
@@ -69,11 +72,11 @@ public:
|
||||
explicit GenericBuildConfigurationFactory(QObject *parent = 0);
|
||||
~GenericBuildConfigurationFactory();
|
||||
|
||||
QList<Core::Id> availableCreationIds(const ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const Core::Id id) const;
|
||||
bool canCreate(const ProjectExplorer::Target *parent) const;
|
||||
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent,
|
||||
const ProjectExplorer::BuildInfo *info) const;
|
||||
|
||||
bool canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name = QString());
|
||||
bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const;
|
||||
ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source);
|
||||
bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
@@ -81,6 +84,7 @@ public:
|
||||
|
||||
private:
|
||||
bool canHandle(const ProjectExplorer::Target *t) const;
|
||||
ProjectExplorer::BuildInfo *createBuildInfo(const ProjectExplorer::Kit *k, const Utils::FileName &buildDir) const;
|
||||
};
|
||||
|
||||
class GenericBuildSettingsWidget : public ProjectExplorer::NamedWidget
|
||||
|
@@ -347,7 +347,7 @@ IBuildConfigurationFactory * IBuildConfigurationFactory::find(Target *parent)
|
||||
QList<IBuildConfigurationFactory *> factories
|
||||
= ExtensionSystem::PluginManager::getObjects<IBuildConfigurationFactory>();
|
||||
foreach (IBuildConfigurationFactory *factory, factories) {
|
||||
if (!factory->availableCreationIds(parent).isEmpty())
|
||||
if (factory->canCreate(parent))
|
||||
return factory;
|
||||
}
|
||||
return 0;
|
||||
|
@@ -41,6 +41,7 @@ namespace Utils { class AbstractMacroExpander; }
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class BuildConfiguration;
|
||||
class BuildInfo;
|
||||
class NamedWidget;
|
||||
class BuildStepList;
|
||||
class Kit;
|
||||
@@ -127,13 +128,13 @@ public:
|
||||
explicit IBuildConfigurationFactory(QObject *parent = 0);
|
||||
virtual ~IBuildConfigurationFactory();
|
||||
|
||||
// used to show the list of possible additons to a target, returns a list of types
|
||||
virtual QList<Core::Id> availableCreationIds(const Target *parent) const = 0;
|
||||
// used to translate the types to names to display to the user
|
||||
virtual QString displayNameForId(const Core::Id id) const = 0;
|
||||
// Used to see whether any BuildInfo is available on this factory for a given target.
|
||||
virtual bool canCreate(const Target *parent) const = 0;
|
||||
// List of build information that can be used to create a new build configuration via
|
||||
// "Add Build Configuration" button.
|
||||
virtual QList<BuildInfo *> availableBuilds(const Target *parent) const = 0;
|
||||
virtual BuildConfiguration *create(Target *parent, const BuildInfo *info) const = 0;
|
||||
|
||||
virtual bool canCreate(const Target *parent, const Core::Id id) const = 0;
|
||||
virtual BuildConfiguration *create(Target *parent, const Core::Id id, const QString &name = QString()) = 0;
|
||||
// used to recreate the runConfigurations when restoring settings
|
||||
virtual bool canRestore(const Target *parent, const QVariantMap &map) const = 0;
|
||||
virtual BuildConfiguration *restore(Target *parent, const QVariantMap &map) = 0;
|
||||
@@ -141,6 +142,7 @@ public:
|
||||
virtual BuildConfiguration *clone(Target *parent, BuildConfiguration *product) = 0;
|
||||
|
||||
static IBuildConfigurationFactory *find(Target *parent, const QVariantMap &map);
|
||||
static IBuildConfigurationFactory *find(Kit *k, const QString &projectPath);
|
||||
static IBuildConfigurationFactory *find(Target *parent);
|
||||
static IBuildConfigurationFactory *find(Target *parent, BuildConfiguration *bc);
|
||||
|
||||
|
74
src/plugins/projectexplorer/buildinfo.h
Normal file
74
src/plugins/projectexplorer/buildinfo.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BUILDINFO_H
|
||||
#define BUILDINFO_H
|
||||
|
||||
#include "projectexplorer_export.h"
|
||||
|
||||
#include "task.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class IBuildConfigurationFactory;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT BuildInfo
|
||||
{
|
||||
public:
|
||||
BuildInfo(const IBuildConfigurationFactory *f) : supportsShadowBuild(false), m_factory(f) { }
|
||||
virtual ~BuildInfo() { }
|
||||
|
||||
const IBuildConfigurationFactory *factory() const { return m_factory; }
|
||||
|
||||
QString displayName;
|
||||
QString typeName;
|
||||
Utils::FileName buildDirectory;
|
||||
Core::Id kitId;
|
||||
bool supportsShadowBuild;
|
||||
|
||||
virtual QList<Task> reportIssues(const QString &projectPath,
|
||||
const QString &buildDir) const
|
||||
{
|
||||
Q_UNUSED(projectPath);
|
||||
Q_UNUSED(buildDir);
|
||||
return QList<Task>();
|
||||
}
|
||||
|
||||
private:
|
||||
const IBuildConfigurationFactory *m_factory;
|
||||
|
||||
friend class IBuildConfigurationFactory;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
#endif // BUILDINFO_H
|
@@ -28,6 +28,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "buildsettingspropertiespage.h"
|
||||
#include "buildinfo.h"
|
||||
#include "buildstepspage.h"
|
||||
#include "project.h"
|
||||
#include "target.h"
|
||||
@@ -35,6 +36,7 @@
|
||||
#include "buildconfigurationmodel.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
|
||||
@@ -97,6 +99,7 @@ PropertiesPanel *BuildSettingsPanelFactory::createPanel(Target *target)
|
||||
BuildSettingsWidget::~BuildSettingsWidget()
|
||||
{
|
||||
clear();
|
||||
qDeleteAll(m_buildInfoList);
|
||||
}
|
||||
|
||||
BuildSettingsWidget::BuildSettingsWidget(Target *target) :
|
||||
@@ -208,17 +211,21 @@ QList<NamedWidget *> BuildSettingsWidget::subWidgets() const
|
||||
void BuildSettingsWidget::updateAddButtonMenu()
|
||||
{
|
||||
m_addButtonMenu->clear();
|
||||
qDeleteAll(m_buildInfoList);
|
||||
m_buildInfoList.clear();
|
||||
|
||||
if (m_target) {
|
||||
if (m_target->activeBuildConfiguration()) {
|
||||
m_addButtonMenu->addAction(tr("&Clone Selected"),
|
||||
this, SLOT(cloneConfiguration()));
|
||||
}
|
||||
IBuildConfigurationFactory * factory = IBuildConfigurationFactory::find(m_target);
|
||||
IBuildConfigurationFactory *factory = IBuildConfigurationFactory::find(m_target);
|
||||
if (!factory)
|
||||
return;
|
||||
foreach (Core::Id id, factory->availableCreationIds(m_target)) {
|
||||
QAction *action = m_addButtonMenu->addAction(factory->displayNameForId(id), this, SLOT(createConfiguration()));
|
||||
action->setData(QVariant::fromValue(id));
|
||||
m_buildInfoList = factory->availableBuilds(m_target);
|
||||
foreach (BuildInfo *info, m_buildInfoList) {
|
||||
QAction *action = m_addButtonMenu->addAction(info->typeName, this, SLOT(createConfiguration()));
|
||||
action->setData(QVariant::fromValue(static_cast<void *>(info)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,19 +276,24 @@ void BuildSettingsWidget::updateActiveConfiguration()
|
||||
void BuildSettingsWidget::createConfiguration()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
Core::Id id = action->data().value<Core::Id>();
|
||||
BuildInfo *info = static_cast<BuildInfo *>(action->data().value<void*>());
|
||||
|
||||
IBuildConfigurationFactory *factory = IBuildConfigurationFactory::find(m_target);
|
||||
if (!factory)
|
||||
return;
|
||||
if (info->displayName.isEmpty()) {
|
||||
bool ok = false;
|
||||
info->displayName = QInputDialog::getText(Core::ICore::mainWindow(),
|
||||
tr("New Configuration"),
|
||||
tr("New configuration name:"),
|
||||
QLineEdit::Normal,
|
||||
QString(), &ok).trimmed();
|
||||
if (!ok || info->displayName.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
BuildConfiguration *bc = factory->create(m_target, id);
|
||||
BuildConfiguration *bc = info->factory()->create(m_target, info);
|
||||
if (!bc)
|
||||
return;
|
||||
|
||||
m_target->addBuildConfiguration(bc);
|
||||
|
||||
QTC_CHECK(bc->id() == id);
|
||||
m_target->setActiveBuildConfiguration(bc);
|
||||
}
|
||||
|
||||
|
@@ -44,6 +44,7 @@ QT_END_NAMESPACE
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class BuildConfiguration;
|
||||
class BuildInfo;
|
||||
class IBuildStepFactory;
|
||||
class NamedWidget;
|
||||
|
||||
@@ -104,6 +105,7 @@ private:
|
||||
|
||||
QList<NamedWidget *> m_subWidgets;
|
||||
QList<QLabel *> m_labels;
|
||||
QList<BuildInfo *> m_buildInfoList;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "project.h"
|
||||
|
||||
#include "buildinfo.h"
|
||||
#include "buildconfiguration.h"
|
||||
#include "editorconfiguration.h"
|
||||
#include "projectexplorer.h"
|
||||
@@ -476,6 +477,36 @@ bool Project::needsSpecialDeployment() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void Project::setup(QList<const BuildInfo *> infoList)
|
||||
{
|
||||
QList<Target *> toRegister;
|
||||
foreach (const BuildInfo *info, infoList) {
|
||||
Kit *k = KitManager::find(info->kitId);
|
||||
if (!k)
|
||||
continue;
|
||||
Target *t = target(k);
|
||||
if (!t) {
|
||||
foreach (Target *i, toRegister) {
|
||||
if (i->kit() == k) {
|
||||
t = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!t) {
|
||||
t = new Target(this, k);
|
||||
toRegister << t;
|
||||
}
|
||||
|
||||
BuildConfiguration *bc = info->factory()->create(t, info);
|
||||
if (!bc)
|
||||
continue;
|
||||
t->addBuildConfiguration(bc);
|
||||
}
|
||||
foreach (Target *t, toRegister)
|
||||
addTarget(t);
|
||||
}
|
||||
|
||||
void Project::onBuildDirectoryChanged()
|
||||
{
|
||||
Target *target = qobject_cast<Target *>(sender());
|
||||
|
@@ -44,6 +44,7 @@ class Context;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class BuildInfo;
|
||||
class IProjectManager;
|
||||
class EditorConfiguration;
|
||||
class ProjectNode;
|
||||
@@ -127,6 +128,8 @@ public:
|
||||
|
||||
virtual bool needsSpecialDeployment() const;
|
||||
|
||||
void setup(QList<const BuildInfo *> infoList);
|
||||
|
||||
signals:
|
||||
void displayNameChanged();
|
||||
void fileListChanged();
|
||||
|
@@ -6,6 +6,7 @@ HEADERS += projectexplorer.h \
|
||||
abi.h \
|
||||
abiwidget.h \
|
||||
ansifilterparser.h \
|
||||
buildinfo.h \
|
||||
clangparser.h \
|
||||
environmentaspect.h \
|
||||
environmentaspectwidget.h \
|
||||
|
@@ -33,6 +33,7 @@ QtcPlugin {
|
||||
"buildconfiguration.cpp", "buildconfiguration.h",
|
||||
"buildconfigurationmodel.cpp", "buildconfigurationmodel.h",
|
||||
"buildenvironmentwidget.cpp", "buildenvironmentwidget.h",
|
||||
"buildinfo.h",
|
||||
"buildmanager.cpp", "buildmanager.h",
|
||||
"buildprogress.cpp", "buildprogress.h",
|
||||
"buildsettingspropertiespage.cpp", "buildsettingspropertiespage.h",
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "target.h"
|
||||
|
||||
#include "buildinfo.h"
|
||||
#include "buildtargetinfo.h"
|
||||
#include "deploymentdata.h"
|
||||
#include "kit.h"
|
||||
@@ -527,16 +528,14 @@ void Target::updateDefaultBuildConfigurations()
|
||||
qWarning("No build configuration factory found for target id '%s'.", qPrintable(id().toString()));
|
||||
return;
|
||||
}
|
||||
QList<Core::Id> bcIds = bcFactory->availableCreationIds(this);
|
||||
foreach (Core::Id id, bcIds) {
|
||||
if (!bcFactory->canCreate(this, id))
|
||||
continue;
|
||||
BuildConfiguration *bc = bcFactory->create(this, id, tr("Default build"));
|
||||
QList<BuildInfo *> infoList = bcFactory->availableBuilds(this);
|
||||
foreach (BuildInfo *info, infoList) {
|
||||
BuildConfiguration *bc = bcFactory->create(this, info);
|
||||
if (!bc)
|
||||
continue;
|
||||
QTC_CHECK(bc->id() == id);
|
||||
addBuildConfiguration(bc);
|
||||
}
|
||||
qDeleteAll(infoList);
|
||||
}
|
||||
|
||||
void Target::updateDefaultDeployConfigurations()
|
||||
|
@@ -30,11 +30,14 @@
|
||||
#include "qbsbuildconfiguration.h"
|
||||
|
||||
#include "qbsbuildconfigurationwidget.h"
|
||||
#include "qbsbuildinfo.h"
|
||||
#include "qbsbuildstep.h"
|
||||
#include "qbscleanstep.h"
|
||||
#include "qbsproject.h"
|
||||
#include "qbsprojectmanagerconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
@@ -238,66 +241,57 @@ bool QbsBuildConfigurationFactory::canHandle(const ProjectExplorer::Target *t) c
|
||||
return qobject_cast<Internal::QbsProject *>(t->project());
|
||||
}
|
||||
|
||||
QList<Core::Id> QbsBuildConfigurationFactory::availableCreationIds(const ProjectExplorer::Target *parent) const
|
||||
ProjectExplorer::BuildInfo *QbsBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k,
|
||||
const Utils::FileName &buildDirectory,
|
||||
ProjectExplorer::BuildConfiguration::BuildType type) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
return QList<Core::Id>() << Core::Id(QBS_BC_ID);
|
||||
QbsBuildInfo *info = new QbsBuildInfo(this);
|
||||
info->typeName = tr("Build");
|
||||
info->buildDirectory = buildDirectory;
|
||||
info->kitId = k->id();
|
||||
info->type = type;
|
||||
return info;
|
||||
}
|
||||
|
||||
QString QbsBuildConfigurationFactory::displayNameForId(const Core::Id id) const
|
||||
bool QbsBuildConfigurationFactory::canCreate(const ProjectExplorer::Target *parent) const
|
||||
{
|
||||
if (id == QBS_BC_ID)
|
||||
return tr("Qbs based build");
|
||||
return QString();
|
||||
return canHandle(parent);
|
||||
}
|
||||
|
||||
bool QbsBuildConfigurationFactory::canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const
|
||||
QList<ProjectExplorer::BuildInfo *> QbsBuildConfigurationFactory::availableBuilds(const ProjectExplorer::Target *parent) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return id == QBS_BC_ID;
|
||||
QList<ProjectExplorer::BuildInfo *> result;
|
||||
QTC_ASSERT(canCreate(parent), return result);
|
||||
|
||||
const Utils::FileName buildDirectory = QbsProject::defaultBuildDirectory(parent->project()->projectFilePath());
|
||||
|
||||
ProjectExplorer::BuildInfo *info = createBuildInfo(parent->kit(), buildDirectory,
|
||||
ProjectExplorer::BuildConfiguration::Debug);
|
||||
result << info;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildConfiguration *QbsBuildConfigurationFactory::create(ProjectExplorer::Target *parent,
|
||||
const Core::Id id,
|
||||
const QString &name)
|
||||
const ProjectExplorer::BuildInfo *info) const
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
QTC_ASSERT(canCreate(parent), return 0);
|
||||
QTC_ASSERT(info->factory() == this, return 0);
|
||||
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
||||
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
||||
|
||||
Internal::QbsProject *project = static_cast<Internal::QbsProject *>(parent->project());
|
||||
|
||||
bool ok = true;
|
||||
QString buildConfigurationName = name;
|
||||
if (buildConfigurationName.isNull())
|
||||
buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New Configuration"),
|
||||
tr("New configuration name:"),
|
||||
QLineEdit::Normal,
|
||||
QString(), &ok);
|
||||
buildConfigurationName = buildConfigurationName.trimmed();
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return 0;
|
||||
|
||||
//: Debug build configuration. We recommend not translating it.
|
||||
QString firstName = tr("%1 Debug").arg(buildConfigurationName).trimmed();
|
||||
|
||||
//: Release build configuration. We recommend not translating it.
|
||||
QString secondName = tr("%1 Release").arg(buildConfigurationName).trimmed();
|
||||
const QbsBuildInfo *qbsInfo = static_cast<const QbsBuildInfo *>(info);
|
||||
|
||||
QVariantMap configData;
|
||||
configData.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY),
|
||||
QLatin1String(Constants::QBS_VARIANT_DEBUG));
|
||||
(qbsInfo->type == ProjectExplorer::BuildConfiguration::Release)
|
||||
? QLatin1String(Constants::QBS_VARIANT_RELEASE)
|
||||
: QLatin1String(Constants::QBS_VARIANT_DEBUG));
|
||||
|
||||
ProjectExplorer::BuildConfiguration *bc
|
||||
= QbsBuildConfiguration::setup(parent, firstName, firstName,
|
||||
configData, project->defaultBuildDirectory());
|
||||
configData.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY),
|
||||
QLatin1String(Constants::QBS_VARIANT_RELEASE));
|
||||
parent->addBuildConfiguration(
|
||||
QbsBuildConfiguration::setup(parent, secondName, secondName,
|
||||
configData, project->defaultBuildDirectory()));
|
||||
= QbsBuildConfiguration::setup(parent, info->displayName, info->displayName,
|
||||
configData, info->buildDirectory);
|
||||
|
||||
return bc;
|
||||
}
|
||||
|
||||
|
@@ -112,11 +112,11 @@ public:
|
||||
explicit QbsBuildConfigurationFactory(QObject *parent = 0);
|
||||
~QbsBuildConfigurationFactory();
|
||||
|
||||
QList<Core::Id> availableCreationIds(const ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const Core::Id id) const;
|
||||
bool canCreate(const ProjectExplorer::Target *parent) const;
|
||||
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent,
|
||||
const ProjectExplorer::BuildInfo *info) const;
|
||||
|
||||
bool canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name = QString());
|
||||
bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const;
|
||||
ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source);
|
||||
bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
@@ -124,6 +124,9 @@ public:
|
||||
|
||||
private:
|
||||
bool canHandle(const ProjectExplorer::Target *t) const;
|
||||
ProjectExplorer::BuildInfo *createBuildInfo(const ProjectExplorer::Kit *k,
|
||||
const Utils::FileName &buildDirectory,
|
||||
ProjectExplorer::BuildConfiguration::BuildType type) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
52
src/plugins/qbsprojectmanager/qbsbuildinfo.h
Normal file
52
src/plugins/qbsprojectmanager/qbsbuildinfo.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QBSBUILDINFO_H
|
||||
#define QBSBUILDINFO_H
|
||||
|
||||
#include "qbsbuildconfiguration.h"
|
||||
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
|
||||
namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class QbsBuildInfo : public ProjectExplorer::BuildInfo
|
||||
{
|
||||
public:
|
||||
QbsBuildInfo(const QbsBuildConfigurationFactory *f) : ProjectExplorer::BuildInfo(f) { }
|
||||
|
||||
ProjectExplorer::BuildConfiguration::BuildType type;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QbsProjectManager
|
||||
|
||||
#endif // QBSBUILDINFO_H
|
@@ -235,7 +235,12 @@ bool QbsProject::hasParseResult() const
|
||||
|
||||
FileName QbsProject::defaultBuildDirectory() const
|
||||
{
|
||||
QFileInfo fi(m_fileName);
|
||||
return defaultBuildDirectory(m_fileName);
|
||||
}
|
||||
|
||||
Utils::FileName QbsProject::defaultBuildDirectory(const QString &path)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
const QString buildDir = QDir(fi.canonicalPath()).absoluteFilePath(QString::fromLatin1("../%1-build").arg(fi.baseName()));
|
||||
return FileName::fromString(buildDir);
|
||||
}
|
||||
|
@@ -93,6 +93,7 @@ public:
|
||||
bool hasParseResult() const;
|
||||
|
||||
Utils::FileName defaultBuildDirectory() const;
|
||||
static Utils::FileName defaultBuildDirectory(const QString &path);
|
||||
|
||||
qbs::Project qbsProject() const;
|
||||
const qbs::ProjectData qbsProjectData() const;
|
||||
|
@@ -20,6 +20,7 @@ HEADERS = \
|
||||
propertyprovider.h \
|
||||
qbsbuildconfiguration.h \
|
||||
qbsbuildconfigurationwidget.h \
|
||||
qbsbuildinfo.h \
|
||||
qbsbuildstep.h \
|
||||
qbscleanstep.h \
|
||||
qbsdeployconfigurationfactory.h \
|
||||
|
@@ -61,6 +61,7 @@ QtcPlugin {
|
||||
"qbsbuildconfiguration.h",
|
||||
"qbsbuildconfigurationwidget.cpp",
|
||||
"qbsbuildconfigurationwidget.h",
|
||||
"qbsbuildinfo.h",
|
||||
"qbsbuildstep.cpp",
|
||||
"qbsbuildstep.h",
|
||||
"qbsbuildstepconfigwidget.ui",
|
||||
|
52
src/plugins/qt4projectmanager/qmakebuildinfo.h
Normal file
52
src/plugins/qt4projectmanager/qmakebuildinfo.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMAKEBUILDINFO_H
|
||||
#define QMAKEBUILDINFO_H
|
||||
|
||||
#include "qt4buildconfiguration.h"
|
||||
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
|
||||
class QmakeBuildInfo : public ProjectExplorer::BuildInfo
|
||||
{
|
||||
public:
|
||||
QmakeBuildInfo(const Qt4BuildConfigurationFactory *f) : ProjectExplorer::BuildInfo(f) { }
|
||||
|
||||
ProjectExplorer::BuildConfiguration::BuildType type;
|
||||
QString additionalArguments;
|
||||
QString makefile;
|
||||
};
|
||||
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
#endif // QMAKEBUILDINFO_H
|
@@ -29,17 +29,20 @@
|
||||
|
||||
#include "qt4buildconfiguration.h"
|
||||
|
||||
#include "buildconfigurationinfo.h"
|
||||
#include "qmakebuildinfo.h"
|
||||
#include "qt4project.h"
|
||||
#include "qt4projectconfigwidget.h"
|
||||
#include "qt4projectmanagerconstants.h"
|
||||
#include "qt4nodes.h"
|
||||
#include "qmakestep.h"
|
||||
#include "makestep.h"
|
||||
#include "buildconfigurationinfo.h"
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <limits>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
@@ -48,6 +51,7 @@
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <qt4projectmanager/qmakekitinformation.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QInputDialog>
|
||||
@@ -532,69 +536,71 @@ bool Qt4BuildConfigurationFactory::canHandle(const Target *t) const
|
||||
return qobject_cast<Qt4Project *>(t->project());
|
||||
}
|
||||
|
||||
QList<Core::Id> Qt4BuildConfigurationFactory::availableCreationIds(const Target *parent) const
|
||||
QmakeBuildInfo *Qt4BuildConfigurationFactory::createBuildInfo(const Kit *k,
|
||||
const QString &projectPath,
|
||||
BuildConfiguration::BuildType type) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
return QList<Core::Id>() << Core::Id(QT4_BC_ID);
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
QmakeBuildInfo *info = new QmakeBuildInfo(this);
|
||||
if (type == BuildConfiguration::Release)
|
||||
//: The name of the release build configuration created by default for a qmake project.
|
||||
info->displayName = tr("Release");
|
||||
else
|
||||
//: The name of the debug build configuration created by default for a qmake project.
|
||||
info->displayName = tr("Debug");
|
||||
info->typeName = tr("Build");
|
||||
// Leave info->buildDirectory unset;
|
||||
info->kitId = k->id();
|
||||
info->supportsShadowBuild = (version && version->supportsShadowBuilds());
|
||||
if (info->supportsShadowBuild)
|
||||
info->buildDirectory = Utils::FileName::fromString(Qt4Project::shadowBuildDirectory(projectPath, k, info->displayName));
|
||||
else
|
||||
info->buildDirectory = Utils::FileName::fromString(ProjectExplorer::Project::projectDirectory(projectPath));
|
||||
info->type = type;
|
||||
return info;
|
||||
}
|
||||
|
||||
QString Qt4BuildConfigurationFactory::displayNameForId(const Core::Id id) const
|
||||
bool Qt4BuildConfigurationFactory::canCreate(const Target *parent) const
|
||||
{
|
||||
if (id == QT4_BC_ID)
|
||||
return tr("Qmake based build");
|
||||
return QString();
|
||||
return canHandle(parent);
|
||||
}
|
||||
|
||||
bool Qt4BuildConfigurationFactory::canCreate(const Target *parent, const Core::Id id) const
|
||||
QList<BuildInfo *> Qt4BuildConfigurationFactory::availableBuilds(const Target *parent) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return id == QT4_BC_ID;
|
||||
QList<ProjectExplorer::BuildInfo *> result;
|
||||
QTC_ASSERT(canCreate(parent), return result);
|
||||
|
||||
QmakeBuildInfo *info = createBuildInfo(parent->kit(), parent->project()->projectFilePath(),
|
||||
BuildConfiguration::Debug);
|
||||
info->displayName.clear(); // ask for a name
|
||||
result << info;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BuildConfiguration *Qt4BuildConfigurationFactory::create(Target *parent, const Core::Id id, const QString &name)
|
||||
BuildConfiguration *Qt4BuildConfigurationFactory::create(Target *parent, const BuildInfo *info) const
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
QTC_ASSERT(canCreate(parent), return 0);
|
||||
QTC_ASSERT(info->factory() == this, return 0);
|
||||
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
||||
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
||||
|
||||
BaseQtVersion *version = QtKitInformation::qtVersion(parent->kit());
|
||||
Q_ASSERT(version);
|
||||
const QmakeBuildInfo *qmakeInfo = static_cast<const QmakeBuildInfo *>(info);
|
||||
|
||||
bool ok = true;
|
||||
QString buildConfigurationName = name;
|
||||
if (buildConfigurationName.isNull())
|
||||
buildConfigurationName = QInputDialog::getText(0,
|
||||
tr("New Configuration"),
|
||||
tr("New configuration name:"),
|
||||
QLineEdit::Normal,
|
||||
version->displayName(), &ok);
|
||||
buildConfigurationName = buildConfigurationName.trimmed();
|
||||
if (!ok || buildConfigurationName.isEmpty())
|
||||
return 0;
|
||||
BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(parent->kit());
|
||||
QTC_ASSERT(version, return 0);
|
||||
|
||||
//: Debug build configuration. We recommend not translating it.
|
||||
QString defaultFirstName = tr("%1 Debug").arg(version->displayName()).trimmed();
|
||||
QString customFirstName;
|
||||
if (buildConfigurationName != version->displayName())
|
||||
customFirstName = tr("%1 Debug").arg(buildConfigurationName).trimmed();
|
||||
BaseQtVersion::QmakeBuildConfigs config = version->defaultBuildConfig();
|
||||
if (qmakeInfo->type == BuildConfiguration::Release)
|
||||
config &= ~QtSupport::BaseQtVersion::DebugBuild;
|
||||
else
|
||||
config |= QtSupport::BaseQtVersion::DebugBuild;
|
||||
|
||||
//: Release build configuration. We recommend not translating it.
|
||||
QString defaultSecondName = tr("%1 Release").arg(version->displayName()).trimmed();
|
||||
QString customSecondName;
|
||||
if (buildConfigurationName != version->displayName())
|
||||
customSecondName = tr("%1 Release").arg(buildConfigurationName).trimmed();
|
||||
|
||||
BaseQtVersion::QmakeBuildConfigs config = version->defaultBuildConfig() | QtSupport::BaseQtVersion::DebugBuild;
|
||||
BuildConfiguration *bc
|
||||
= Qt4BuildConfiguration::setup(parent, defaultFirstName, customFirstName,
|
||||
config, QString(), QString(), false);
|
||||
= Qt4BuildConfiguration::setup(parent, info->displayName, info->displayName,
|
||||
config, qmakeInfo->additionalArguments,
|
||||
info->buildDirectory.toString(), false);
|
||||
|
||||
config = config ^ BaseQtVersion::DebugBuild;
|
||||
parent->addBuildConfiguration(
|
||||
Qt4BuildConfiguration::setup(parent, defaultSecondName, customSecondName,
|
||||
config,
|
||||
QString(), QString(), false));
|
||||
return bc;
|
||||
}
|
||||
|
||||
@@ -672,6 +678,8 @@ Qt4BuildConfiguration *Qt4BuildConfiguration::setup(Target *t, QString defaultDi
|
||||
QString additionalArguments, QString directory,
|
||||
bool importing)
|
||||
{
|
||||
Q_UNUSED(importing);
|
||||
|
||||
// Add the build configuration.
|
||||
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(t);
|
||||
bc->setDefaultDisplayName(defaultDisplayName);
|
||||
@@ -695,10 +703,10 @@ Qt4BuildConfiguration *Qt4BuildConfiguration::setup(Target *t, QString defaultDi
|
||||
|
||||
bool enableQmlDebugger
|
||||
= Qt4BuildConfiguration::removeQMLInspectorFromArguments(&additionalArguments);
|
||||
|
||||
if (!additionalArguments.isEmpty())
|
||||
qmakeStep->setUserArguments(additionalArguments);
|
||||
if (importing)
|
||||
qmakeStep->setLinkQmlDebuggingLibrary(enableQmlDebugger);
|
||||
qmakeStep->setLinkQmlDebuggingLibrary(enableQmlDebugger);
|
||||
|
||||
bc->setQMakeBuildConfiguration(qmakeBuildConfiguration);
|
||||
|
||||
|
@@ -39,6 +39,7 @@ namespace ProjectExplorer { class FileNode; }
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
|
||||
class QmakeBuildInfo;
|
||||
class QMakeStep;
|
||||
class MakeStep;
|
||||
class Qt4BuildConfigurationFactory;
|
||||
@@ -171,11 +172,11 @@ public:
|
||||
explicit Qt4BuildConfigurationFactory(QObject *parent = 0);
|
||||
~Qt4BuildConfigurationFactory();
|
||||
|
||||
QList<Core::Id> availableCreationIds(const ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const Core::Id id) const;
|
||||
bool canCreate(const ProjectExplorer::Target *parent) const;
|
||||
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent,
|
||||
const ProjectExplorer::BuildInfo *info) const;
|
||||
|
||||
bool canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name = QString());
|
||||
bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const;
|
||||
ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source);
|
||||
bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
@@ -189,6 +190,8 @@ private slots:
|
||||
|
||||
private:
|
||||
bool canHandle(const ProjectExplorer::Target *t) const;
|
||||
QmakeBuildInfo *createBuildInfo(const ProjectExplorer::Kit *k, const QString &projectPath,
|
||||
ProjectExplorer::BuildConfiguration::BuildType type) const;
|
||||
};
|
||||
|
||||
} // namespace Qt4ProjectManager
|
||||
|
@@ -5,6 +5,7 @@ DEFINES += \
|
||||
QT4PROJECTMANAGER_LIBRARY
|
||||
|
||||
HEADERS += \
|
||||
qmakebuildinfo.h \
|
||||
qmakekitinformation.h \
|
||||
qmakekitconfigwidget.h \
|
||||
qmakerunconfigurationfactory.h \
|
||||
|
@@ -36,6 +36,7 @@ QtcPlugin {
|
||||
"profilehighlighter.cpp", "profilehighlighter.h",
|
||||
"profilehighlighterfactory.cpp", "profilehighlighterfactory.h",
|
||||
"profilehoverhandler.cpp", "profilehoverhandler.h",
|
||||
"qmakebuildinfo.h",
|
||||
"qmakeparser.cpp", "qmakeparser.h",
|
||||
"qmakekitconfigwidget.cpp", "qmakekitconfigwidget.h",
|
||||
"qmakekitinformation.cpp", "qmakekitinformation.h",
|
||||
|
Reference in New Issue
Block a user