2010-02-08 15:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "target.h"
|
|
|
|
|
|
2011-08-18 13:46:52 +02:00
|
|
|
#include "toolchain.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "buildconfiguration.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "deployconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "project.h"
|
2010-09-09 17:00:26 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "runconfiguration.h"
|
2011-02-01 18:36:00 +01:00
|
|
|
#include "toolchainmanager.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-09-09 17:00:26 +02:00
|
|
|
#include <limits>
|
2011-03-09 12:07:35 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
#include <QtGui/QIcon>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
namespace {
|
2011-11-02 16:45:13 +01:00
|
|
|
const char ACTIVE_BC_KEY[] = "ProjectExplorer.Target.ActiveBuildConfiguration";
|
|
|
|
|
const char BC_KEY_PREFIX[] = "ProjectExplorer.Target.BuildConfiguration.";
|
|
|
|
|
const char BC_COUNT_KEY[] = "ProjectExplorer.Target.BuildConfigurationCount";
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-11-02 16:45:13 +01:00
|
|
|
const char ACTIVE_DC_KEY[] = "ProjectExplorer.Target.ActiveDeployConfiguration";
|
|
|
|
|
const char DC_KEY_PREFIX[] = "ProjectExplorer.Target.DeployConfiguration.";
|
|
|
|
|
const char DC_COUNT_KEY[] = "ProjectExplorer.Target.DeployConfigurationCount";
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2011-11-02 16:45:13 +01:00
|
|
|
const char ACTIVE_RC_KEY[] = "ProjectExplorer.Target.ActiveRunConfiguration";
|
|
|
|
|
const char RC_KEY_PREFIX[] = "ProjectExplorer.Target.RunConfiguration.";
|
|
|
|
|
const char RC_COUNT_KEY[] = "ProjectExplorer.Target.RunConfigurationCount";
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Target
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
class TargetPrivate
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
public:
|
|
|
|
|
TargetPrivate();
|
2011-03-09 12:07:35 +01:00
|
|
|
|
|
|
|
|
QList<DeployConfigurationFactory *> deployFactories() const;
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
bool m_isEnabled;
|
|
|
|
|
QIcon m_icon;
|
|
|
|
|
QIcon m_overlayIcon;
|
|
|
|
|
QString m_toolTip;
|
|
|
|
|
|
|
|
|
|
QList<BuildConfiguration *> m_buildConfigurations;
|
|
|
|
|
BuildConfiguration *m_activeBuildConfiguration;
|
|
|
|
|
QList<DeployConfiguration *> m_deployConfigurations;
|
|
|
|
|
DeployConfiguration *m_activeDeployConfiguration;
|
|
|
|
|
QList<RunConfiguration *> m_runConfigurations;
|
|
|
|
|
RunConfiguration* m_activeRunConfiguration;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TargetPrivate::TargetPrivate() :
|
2010-02-08 15:50:06 +01:00
|
|
|
m_isEnabled(true),
|
|
|
|
|
m_activeBuildConfiguration(0),
|
2010-07-16 14:00:41 +02:00
|
|
|
m_activeDeployConfiguration(0),
|
2010-02-08 15:50:06 +01:00
|
|
|
m_activeRunConfiguration(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-09 12:07:35 +01:00
|
|
|
QList<DeployConfigurationFactory *> TargetPrivate::deployFactories() const
|
|
|
|
|
{
|
|
|
|
|
return ExtensionSystem::PluginManager::instance()->getObjects<DeployConfigurationFactory>();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
|
|
|
|
|
Target::Target(Project *project, const QString &id) :
|
|
|
|
|
ProjectConfiguration(project, id), d(new TargetPrivate)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target::~Target()
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
qDeleteAll(d->m_buildConfigurations);
|
|
|
|
|
qDeleteAll(d->m_runConfigurations);
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::changeEnvironment()
|
|
|
|
|
{
|
2011-04-21 15:01:48 +02:00
|
|
|
BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(sender());
|
2010-02-08 15:50:06 +01:00
|
|
|
if (bc == activeBuildConfiguration())
|
|
|
|
|
emit environmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-19 15:46:01 +01:00
|
|
|
void Target::changeBuildConfigurationEnabled()
|
|
|
|
|
{
|
2011-04-21 15:01:48 +02:00
|
|
|
BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(sender());
|
2011-01-19 15:46:01 +01:00
|
|
|
if (bc == activeBuildConfiguration())
|
|
|
|
|
emit buildConfigurationEnabledChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Project *Target::project() const
|
|
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return static_cast<Project *>(parent());
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::addBuildConfiguration(BuildConfiguration *configuration)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
QTC_ASSERT(configuration && !d->m_buildConfigurations.contains(configuration), return);
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(configuration->target() == this);
|
|
|
|
|
|
|
|
|
|
if (!buildConfigurationFactory())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Check that we don't have a configuration with the same displayName
|
|
|
|
|
QString configurationDisplayName = configuration->displayName();
|
|
|
|
|
QStringList displayNames;
|
2010-09-21 09:17:37 +02:00
|
|
|
foreach (const BuildConfiguration *bc, d->m_buildConfigurations)
|
2010-02-08 15:50:06 +01:00
|
|
|
displayNames << bc->displayName();
|
|
|
|
|
configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames);
|
2011-05-20 12:52:59 +02:00
|
|
|
if (configurationDisplayName != configuration->displayName()) {
|
|
|
|
|
if (configuration->usesDefaultDisplayName()) {
|
|
|
|
|
configuration->setDefaultDisplayName(configurationDisplayName);
|
|
|
|
|
} else {
|
|
|
|
|
configuration->setDisplayName(configurationDisplayName);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-04-14 14:53:45 +02:00
|
|
|
// Make sure we have a sane tool chain if at all possible
|
|
|
|
|
if (!configuration->toolChain()
|
|
|
|
|
|| !possibleToolChains(configuration).contains(configuration->toolChain()))
|
|
|
|
|
configuration->setToolChain(preferredToolChain(configuration));
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
// add it
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_buildConfigurations.push_back(configuration);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
emit addedBuildConfiguration(configuration);
|
|
|
|
|
|
|
|
|
|
connect(configuration, SIGNAL(environmentChanged()),
|
|
|
|
|
SLOT(changeEnvironment()));
|
|
|
|
|
|
2011-01-19 15:46:01 +01:00
|
|
|
connect(configuration, SIGNAL(enabledChanged()),
|
|
|
|
|
this, SLOT(changeBuildConfigurationEnabled()));
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!activeBuildConfiguration())
|
|
|
|
|
setActiveBuildConfiguration(configuration);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-24 13:10:38 +00:00
|
|
|
bool Target::removeBuildConfiguration(BuildConfiguration *configuration)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
//todo: this might be error prone
|
2010-09-21 09:17:37 +02:00
|
|
|
if (!d->m_buildConfigurations.contains(configuration))
|
2011-10-24 13:10:38 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::BuildManager *bm =
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager();
|
|
|
|
|
if (bm->isBuilding(configuration))
|
|
|
|
|
return false;
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_buildConfigurations.removeOne(configuration);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
emit removedBuildConfiguration(configuration);
|
|
|
|
|
|
|
|
|
|
if (activeBuildConfiguration() == configuration) {
|
2010-09-21 09:17:37 +02:00
|
|
|
if (d->m_buildConfigurations.isEmpty())
|
2010-02-08 15:50:06 +01:00
|
|
|
setActiveBuildConfiguration(0);
|
|
|
|
|
else
|
2010-09-21 09:17:37 +02:00
|
|
|
setActiveBuildConfiguration(d->m_buildConfigurations.at(0));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete configuration;
|
2011-10-24 13:10:38 +00:00
|
|
|
return true;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BuildConfiguration *> Target::buildConfigurations() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_buildConfigurations;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfiguration *Target::activeBuildConfiguration() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_activeBuildConfiguration;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setActiveBuildConfiguration(BuildConfiguration *configuration)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if ((!configuration && d->m_buildConfigurations.isEmpty()) ||
|
|
|
|
|
(configuration && d->m_buildConfigurations.contains(configuration) &&
|
|
|
|
|
configuration != d->m_activeBuildConfiguration)) {
|
|
|
|
|
d->m_activeBuildConfiguration = configuration;
|
|
|
|
|
emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration);
|
2010-02-08 15:50:06 +01:00
|
|
|
emit environmentChanged();
|
2011-01-19 15:46:01 +01:00
|
|
|
emit buildConfigurationEnabledChanged();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void Target::addDeployConfiguration(DeployConfiguration *dc)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
QTC_ASSERT(dc && !d->m_deployConfigurations.contains(dc), return);
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(dc->target() == this);
|
|
|
|
|
|
2011-03-09 12:07:35 +01:00
|
|
|
if (d->deployFactories().isEmpty())
|
2010-07-16 14:00:41 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Check that we don't have a configuration with the same displayName
|
|
|
|
|
QString configurationDisplayName = dc->displayName();
|
|
|
|
|
QStringList displayNames;
|
2010-09-21 09:17:37 +02:00
|
|
|
foreach (const DeployConfiguration *current, d->m_deployConfigurations)
|
2010-08-18 15:38:42 +02:00
|
|
|
displayNames << current->displayName();
|
2010-07-16 14:00:41 +02:00
|
|
|
configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames);
|
|
|
|
|
dc->setDisplayName(configurationDisplayName);
|
|
|
|
|
|
|
|
|
|
// add it
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_deployConfigurations.push_back(dc);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
emit addedDeployConfiguration(dc);
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
if (!d->m_activeDeployConfiguration)
|
2010-07-16 14:00:41 +02:00
|
|
|
setActiveDeployConfiguration(dc);
|
|
|
|
|
Q_ASSERT(activeDeployConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-24 13:10:38 +00:00
|
|
|
bool Target::removeDeployConfiguration(DeployConfiguration *dc)
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
|
|
|
|
//todo: this might be error prone
|
2010-09-21 09:17:37 +02:00
|
|
|
if (!d->m_deployConfigurations.contains(dc))
|
2011-10-24 13:10:38 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::BuildManager *bm =
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager();
|
|
|
|
|
if (bm->isBuilding(dc))
|
|
|
|
|
return false;
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_deployConfigurations.removeOne(dc);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
emit removedDeployConfiguration(dc);
|
|
|
|
|
|
|
|
|
|
if (activeDeployConfiguration() == dc) {
|
2010-09-21 09:17:37 +02:00
|
|
|
if (d->m_deployConfigurations.isEmpty())
|
2010-07-16 14:00:41 +02:00
|
|
|
setActiveDeployConfiguration(0);
|
|
|
|
|
else
|
2010-09-21 09:17:37 +02:00
|
|
|
setActiveDeployConfiguration(d->m_deployConfigurations.at(0));
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete dc;
|
2011-10-24 13:10:38 +00:00
|
|
|
return true;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<DeployConfiguration *> Target::deployConfigurations() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_deployConfigurations;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeployConfiguration *Target::activeDeployConfiguration() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_activeDeployConfiguration;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setActiveDeployConfiguration(DeployConfiguration *dc)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if ((!dc && d->m_deployConfigurations.isEmpty()) ||
|
|
|
|
|
(dc && d->m_deployConfigurations.contains(dc) &&
|
|
|
|
|
dc != d->m_activeDeployConfiguration)) {
|
|
|
|
|
d->m_activeDeployConfiguration = dc;
|
|
|
|
|
emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration);
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-09 12:07:35 +01:00
|
|
|
QStringList Target::availableDeployConfigurationIds()
|
|
|
|
|
{
|
|
|
|
|
QStringList ids;
|
|
|
|
|
foreach (const DeployConfigurationFactory * const factory, d->deployFactories())
|
|
|
|
|
ids << factory->availableCreationIds(this);
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Target::displayNameForDeployConfigurationId(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
foreach (const DeployConfigurationFactory * const factory, d->deployFactories()) {
|
|
|
|
|
if (factory->availableCreationIds(this).contains(id))
|
|
|
|
|
return factory->displayNameForId(id);
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeployConfiguration *Target::createDeployConfiguration(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
foreach (DeployConfigurationFactory * const factory, d->deployFactories()) {
|
|
|
|
|
if (factory->canCreate(this, id))
|
|
|
|
|
return factory->create(this, id);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QList<RunConfiguration *> Target::runConfigurations() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_runConfigurations;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::addRunConfiguration(RunConfiguration* runConfiguration)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
QTC_ASSERT(runConfiguration && !d->m_runConfigurations.contains(runConfiguration), return);
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(runConfiguration->target() == this);
|
|
|
|
|
|
2010-08-18 15:38:42 +02:00
|
|
|
// Check that we don't have a configuration with the same displayName
|
|
|
|
|
QString configurationDisplayName = runConfiguration->displayName();
|
|
|
|
|
QStringList displayNames;
|
2010-09-21 09:17:37 +02:00
|
|
|
foreach (const RunConfiguration *rc, d->m_runConfigurations)
|
2010-08-18 15:38:42 +02:00
|
|
|
displayNames << rc->displayName();
|
|
|
|
|
configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames);
|
|
|
|
|
runConfiguration->setDisplayName(configurationDisplayName);
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_runConfigurations.push_back(runConfiguration);
|
2010-02-08 15:50:06 +01:00
|
|
|
emit addedRunConfiguration(runConfiguration);
|
|
|
|
|
|
|
|
|
|
if (!activeRunConfiguration())
|
|
|
|
|
setActiveRunConfiguration(runConfiguration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::removeRunConfiguration(RunConfiguration* runConfiguration)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
QTC_ASSERT(runConfiguration && d->m_runConfigurations.contains(runConfiguration), return);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_runConfigurations.removeOne(runConfiguration);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
if (activeRunConfiguration() == runConfiguration) {
|
2010-09-21 09:17:37 +02:00
|
|
|
if (d->m_runConfigurations.isEmpty())
|
2010-02-08 15:50:06 +01:00
|
|
|
setActiveRunConfiguration(0);
|
|
|
|
|
else
|
2010-09-21 09:17:37 +02:00
|
|
|
setActiveRunConfiguration(d->m_runConfigurations.at(0));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit removedRunConfiguration(runConfiguration);
|
|
|
|
|
delete runConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration* Target::activeRunConfiguration() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_activeRunConfiguration;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setActiveRunConfiguration(RunConfiguration* configuration)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if ((!configuration && d->m_runConfigurations.isEmpty()) ||
|
|
|
|
|
(configuration && d->m_runConfigurations.contains(configuration) &&
|
|
|
|
|
configuration != d->m_activeRunConfiguration)) {
|
|
|
|
|
d->m_activeRunConfiguration = configuration;
|
|
|
|
|
emit activeRunConfigurationChanged(d->m_activeRunConfiguration);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Target::isEnabled() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_isEnabled;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QIcon Target::icon() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_icon;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setIcon(QIcon icon)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_icon = icon;
|
2010-02-08 15:50:06 +01:00
|
|
|
emit iconChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-23 16:52:03 +01:00
|
|
|
QIcon Target::overlayIcon() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_overlayIcon;
|
2010-02-23 16:52:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setOverlayIcon(QIcon icon)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_overlayIcon = icon;
|
2010-02-23 16:52:03 +01:00
|
|
|
emit overlayIconChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
QString Target::toolTip() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_toolTip;
|
2010-02-09 19:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setToolTip(const QString &text)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_toolTip = text;
|
2010-02-09 19:05:15 +01:00
|
|
|
emit toolTipChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QList<ToolChain *> Target::possibleToolChains(BuildConfiguration *) const
|
|
|
|
|
{
|
|
|
|
|
QList<ToolChain *> tcList = ToolChainManager::instance()->toolChains();
|
|
|
|
|
QList<ToolChain *> result;
|
|
|
|
|
foreach (ToolChain *tc, tcList) {
|
2011-04-12 18:51:55 +02:00
|
|
|
QStringList restricted = tc->restrictedToTargets();
|
|
|
|
|
if (restricted.isEmpty() || restricted.contains(id()))
|
2011-02-01 18:36:00 +01:00
|
|
|
result.append(tc);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *Target::preferredToolChain(BuildConfiguration *bc) const
|
|
|
|
|
{
|
|
|
|
|
QList<ToolChain *> tcs = possibleToolChains(bc);
|
|
|
|
|
if (tcs.isEmpty())
|
|
|
|
|
return 0;
|
|
|
|
|
return tcs.at(0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QVariantMap Target::toMap() const
|
|
|
|
|
{
|
|
|
|
|
const QList<BuildConfiguration *> bcs = buildConfigurations();
|
|
|
|
|
|
|
|
|
|
QVariantMap map(ProjectConfiguration::toMap());
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(ACTIVE_BC_KEY), bcs.indexOf(d->m_activeBuildConfiguration));
|
2010-02-08 15:50:06 +01:00
|
|
|
map.insert(QLatin1String(BC_COUNT_KEY), bcs.size());
|
|
|
|
|
for (int i = 0; i < bcs.size(); ++i)
|
|
|
|
|
map.insert(QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i), bcs.at(i)->toMap());
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
const QList<DeployConfiguration *> dcs = deployConfigurations();
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(ACTIVE_DC_KEY), dcs.indexOf(d->m_activeDeployConfiguration));
|
2010-07-16 14:00:41 +02:00
|
|
|
map.insert(QLatin1String(DC_COUNT_KEY), dcs.size());
|
|
|
|
|
for (int i = 0; i < dcs.size(); ++i)
|
|
|
|
|
map.insert(QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i), dcs.at(i)->toMap());
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
const QList<RunConfiguration *> rcs = runConfigurations();
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(ACTIVE_RC_KEY), rcs.indexOf(d->m_activeRunConfiguration));
|
2010-02-08 15:50:06 +01:00
|
|
|
map.insert(QLatin1String(RC_COUNT_KEY), rcs.size());
|
|
|
|
|
for (int i = 0; i < rcs.size(); ++i)
|
|
|
|
|
map.insert(QString::fromLatin1(RC_KEY_PREFIX) + QString::number(i), rcs.at(i)->toMap());
|
|
|
|
|
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setEnabled(bool enabled)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if (enabled == d->m_isEnabled)
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_isEnabled = enabled;
|
|
|
|
|
emit targetEnabled(d->m_isEnabled);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Target::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!ProjectConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
bool ok;
|
2011-04-21 15:01:48 +02:00
|
|
|
int bcCount = map.value(QLatin1String(BC_COUNT_KEY), 0).toInt(&ok);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!ok || bcCount < 0)
|
|
|
|
|
bcCount = 0;
|
2011-04-21 15:01:48 +02:00
|
|
|
int activeConfiguration = map.value(QLatin1String(ACTIVE_BC_KEY), 0).toInt(&ok);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!ok || activeConfiguration < 0)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
if (0 > activeConfiguration || bcCount < activeConfiguration)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < bcCount; ++i) {
|
2011-04-21 15:01:48 +02:00
|
|
|
const QString key = QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!map.contains(key))
|
|
|
|
|
return false;
|
2011-04-21 15:01:48 +02:00
|
|
|
BuildConfiguration *bc = buildConfigurationFactory()->restore(this, map.value(key).toMap());
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!bc)
|
|
|
|
|
continue;
|
|
|
|
|
addBuildConfiguration(bc);
|
|
|
|
|
if (i == activeConfiguration)
|
|
|
|
|
setActiveBuildConfiguration(bc);
|
|
|
|
|
}
|
2010-02-19 14:01:49 +01:00
|
|
|
if (buildConfigurations().isEmpty() && buildConfigurationFactory())
|
2010-02-08 15:50:06 +01:00
|
|
|
return false;
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
int dcCount = map.value(QLatin1String(DC_COUNT_KEY), 0).toInt(&ok);
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!ok || dcCount < 0)
|
|
|
|
|
dcCount = 0;
|
|
|
|
|
activeConfiguration = map.value(QLatin1String(ACTIVE_DC_KEY), 0).toInt(&ok);
|
|
|
|
|
if (!ok || activeConfiguration < 0)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
if (0 > activeConfiguration || dcCount < activeConfiguration)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dcCount; ++i) {
|
2011-04-21 15:01:48 +02:00
|
|
|
const QString key = QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i);
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!map.contains(key))
|
|
|
|
|
return false;
|
2010-08-02 15:35:51 +02:00
|
|
|
DeployConfiguration *dc = 0;
|
2011-03-09 12:07:35 +01:00
|
|
|
foreach (DeployConfigurationFactory * const factory, d->deployFactories()) {
|
|
|
|
|
QVariantMap valueMap = map.value(key).toMap();
|
|
|
|
|
if (factory->canRestore(this, valueMap)) {
|
|
|
|
|
dc = factory->restore(this, valueMap);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!dc)
|
|
|
|
|
continue;
|
|
|
|
|
addDeployConfiguration(dc);
|
|
|
|
|
if (i == activeConfiguration)
|
|
|
|
|
setActiveDeployConfiguration(dc);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
int rcCount = map.value(QLatin1String(RC_COUNT_KEY), 0).toInt(&ok);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!ok || rcCount < 0)
|
|
|
|
|
rcCount = 0;
|
|
|
|
|
activeConfiguration = map.value(QLatin1String(ACTIVE_RC_KEY), 0).toInt(&ok);
|
|
|
|
|
if (!ok || activeConfiguration < 0)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
if (0 > activeConfiguration || rcCount < activeConfiguration)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < rcCount; ++i) {
|
2011-04-21 15:01:48 +02:00
|
|
|
const QString key = QString::fromLatin1(RC_KEY_PREFIX) + QString::number(i);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!map.contains(key))
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
QVariantMap valueMap = map.value(key).toMap();
|
|
|
|
|
IRunConfigurationFactory *factory = IRunConfigurationFactory::restoreFactory(this, valueMap);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!factory)
|
|
|
|
|
continue; // Skip RCs we do not know about.)
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
RunConfiguration *rc = factory->restore(this, valueMap);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!rc)
|
|
|
|
|
continue;
|
|
|
|
|
addRunConfiguration(rc);
|
|
|
|
|
if (i == activeConfiguration)
|
|
|
|
|
setActiveRunConfiguration(rc);
|
|
|
|
|
}
|
2010-02-10 14:44:58 +01:00
|
|
|
// Ignore missing RCs: We will just populate them using the default ones.
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// ITargetFactory
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
ITargetFactory::ITargetFactory(QObject *parent) :
|
|
|
|
|
QObject(parent)
|
2011-06-24 16:54:49 +02:00
|
|
|
{
|
|
|
|
|
connect(ToolChainManager::instance(), SIGNAL(toolChainsChanged()),
|
|
|
|
|
this, SIGNAL(supportedTargetIdsChanged()));
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
} // namespace ProjectExplorer
|