2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-07-16 14:00:41 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-07-16 14:00:41 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-07-16 14:00:41 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-07-16 14:00:41 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
#include "deployconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include "buildsteplist.h"
|
2014-11-05 15:45:56 +01:00
|
|
|
#include "buildconfiguration.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kitinformation.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "project.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "target.h"
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2013-09-26 13:01:29 +02:00
|
|
|
const char BUILD_STEP_LIST_COUNT[] = "ProjectExplorer.BuildConfiguration.BuildStepListCount";
|
|
|
|
|
const char BUILD_STEP_LIST_PREFIX[] = "ProjectExplorer.BuildConfiguration.BuildStepList.";
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
DeployConfiguration::DeployConfiguration(Target *target, Core::Id id) :
|
2010-07-16 14:00:41 +02:00
|
|
|
ProjectConfiguration(target, id),
|
|
|
|
|
m_stepList(0)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(target);
|
2012-03-15 17:17:40 +01:00
|
|
|
m_stepList = new BuildStepList(this, Core::Id(Constants::BUILDSTEPS_DEPLOY));
|
2010-07-16 14:00:41 +02:00
|
|
|
//: Display name of the deploy build step list. Used as part of the labels in the project window.
|
2010-08-19 12:26:21 +02:00
|
|
|
m_stepList->setDefaultDisplayName(tr("Deploy"));
|
|
|
|
|
//: Default DeployConfiguration display name
|
2012-04-24 15:49:09 +02:00
|
|
|
setDefaultDisplayName(tr("Deploy locally"));
|
2014-11-05 15:45:56 +01:00
|
|
|
ctor();
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeployConfiguration::DeployConfiguration(Target *target, DeployConfiguration *source) :
|
2012-09-20 14:42:57 +02:00
|
|
|
ProjectConfiguration(target, source),
|
|
|
|
|
m_stepList(0)
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(target);
|
|
|
|
|
// Do not clone stepLists here, do that in the derived constructor instead
|
|
|
|
|
// otherwise BuildStepFactories might reject to set up a BuildStep for us
|
|
|
|
|
// since we are not yet the derived class!
|
2014-11-05 15:45:56 +01:00
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeployConfiguration::ctor()
|
|
|
|
|
{
|
|
|
|
|
Utils::MacroExpander *expander = macroExpander();
|
|
|
|
|
expander->setDisplayName(tr("Deploy Settings"));
|
|
|
|
|
expander->setAccumulating(true);
|
|
|
|
|
expander->registerSubProvider([this]() -> Utils::MacroExpander * {
|
|
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
|
|
|
|
return bc ? bc->macroExpander() : target()->macroExpander();
|
|
|
|
|
});
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeployConfiguration::~DeployConfiguration()
|
|
|
|
|
{
|
|
|
|
|
delete m_stepList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepList *DeployConfiguration::stepList() const
|
|
|
|
|
{
|
|
|
|
|
return m_stepList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap DeployConfiguration::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map(ProjectConfiguration::toMap());
|
|
|
|
|
map.insert(QLatin1String(BUILD_STEP_LIST_COUNT), 1);
|
2014-08-29 14:00:18 +02:00
|
|
|
map.insert(QLatin1String(BUILD_STEP_LIST_PREFIX) + QLatin1Char('0'), m_stepList->toMap());
|
2010-07-16 14:00:41 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-08 15:37:31 +01:00
|
|
|
NamedWidget *DeployConfiguration::createConfigWidget()
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-29 13:16:25 +02:00
|
|
|
bool DeployConfiguration::isEnabled() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString DeployConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
bool DeployConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!ProjectConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
int maxI = map.value(QLatin1String(BUILD_STEP_LIST_COUNT), 0).toInt();
|
2010-08-19 12:26:21 +02:00
|
|
|
if (maxI != 1)
|
|
|
|
|
return false;
|
2014-08-29 14:00:18 +02:00
|
|
|
QVariantMap data = map.value(QLatin1String(BUILD_STEP_LIST_PREFIX) + QLatin1Char('0')).toMap();
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!data.isEmpty()) {
|
2012-09-12 18:05:12 +02:00
|
|
|
delete m_stepList;
|
2010-07-16 14:00:41 +02:00
|
|
|
m_stepList = new BuildStepList(this, data);
|
|
|
|
|
if (m_stepList->isNull()) {
|
|
|
|
|
qWarning() << "Failed to restore deploy step list";
|
|
|
|
|
delete m_stepList;
|
|
|
|
|
m_stepList = 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-19 12:26:21 +02:00
|
|
|
m_stepList->setDefaultDisplayName(tr("Deploy"));
|
2010-07-16 14:00:41 +02:00
|
|
|
} else {
|
|
|
|
|
qWarning() << "No data for deploy step list found!";
|
2010-08-19 12:26:21 +02:00
|
|
|
return false;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-03 17:05:38 +02:00
|
|
|
// We assume that we hold the deploy list
|
2014-10-13 22:37:28 +03:00
|
|
|
Q_ASSERT(m_stepList && m_stepList->id() == Constants::BUILDSTEPS_DEPLOY);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Target *DeployConfiguration::target() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<Target *>(parent());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeployConfiguration::cloneSteps(DeployConfiguration *source)
|
|
|
|
|
{
|
|
|
|
|
if (source == this)
|
|
|
|
|
return;
|
|
|
|
|
delete m_stepList;
|
|
|
|
|
m_stepList = new BuildStepList(this, source->stepList());
|
2010-08-30 12:25:27 +02:00
|
|
|
m_stepList->cloneSteps(source->stepList());
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-12 17:38:08 +02:00
|
|
|
///
|
|
|
|
|
// DefaultDeployConfiguration
|
|
|
|
|
///
|
2014-07-01 11:08:26 +02:00
|
|
|
DefaultDeployConfiguration::DefaultDeployConfiguration(Target *target, Core::Id id)
|
2012-09-12 17:38:08 +02:00
|
|
|
: DeployConfiguration(target, id)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DefaultDeployConfiguration::DefaultDeployConfiguration(Target *target, DeployConfiguration *source)
|
|
|
|
|
: DeployConfiguration(target, source)
|
|
|
|
|
{
|
|
|
|
|
cloneSteps(source);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
///
|
|
|
|
|
// DeployConfigurationFactory
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
DeployConfigurationFactory::DeployConfigurationFactory(QObject *parent) :
|
|
|
|
|
QObject(parent)
|
2012-04-24 15:49:09 +02:00
|
|
|
{ setObjectName(QLatin1String("DeployConfigurationFactory")); }
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
DeployConfigurationFactory::~DeployConfigurationFactory()
|
|
|
|
|
{ }
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> DeployConfigurationFactory::availableCreationIds(Target *parent) const
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return QList<Core::Id>();
|
2012-03-15 17:17:40 +01:00
|
|
|
return QList<Core::Id>() << Core::Id(Constants::DEFAULT_DEPLOYCONFIGURATION_ID);
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
QString DeployConfigurationFactory::displayNameForId(Core::Id id) const
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (id == Constants::DEFAULT_DEPLOYCONFIGURATION_ID)
|
2010-07-16 14:00:41 +02:00
|
|
|
//: Display name of the default deploy configuration
|
|
|
|
|
return tr("Deploy Configuration");
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
bool DeployConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return false;
|
2012-08-03 15:24:33 +02:00
|
|
|
return id == Constants::DEFAULT_DEPLOYCONFIGURATION_ID;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
DeployConfiguration *DeployConfigurationFactory::create(Target *parent, Core::Id id)
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
|
return 0;
|
2012-09-12 17:38:08 +02:00
|
|
|
return new DefaultDeployConfiguration(parent, id);
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
|
|
|
|
{
|
|
|
|
|
return canCreate(parent, idFromMap(map));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeployConfiguration *DeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
2012-09-12 17:38:08 +02:00
|
|
|
DefaultDeployConfiguration *dc = new DefaultDeployConfiguration(parent, idFromMap(map));
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!dc->fromMap(map)) {
|
|
|
|
|
delete dc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return dc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DeployConfigurationFactory::canClone(Target *parent, DeployConfiguration *product) const
|
|
|
|
|
{
|
|
|
|
|
return canCreate(parent, product->id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeployConfiguration *DeployConfigurationFactory::clone(Target *parent, DeployConfiguration *product)
|
|
|
|
|
{
|
|
|
|
|
if (!canClone(parent, product))
|
|
|
|
|
return 0;
|
2012-09-12 17:38:08 +02:00
|
|
|
return new DefaultDeployConfiguration(parent, product);
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
|
|
|
|
{
|
2014-05-08 11:58:23 +02:00
|
|
|
return ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>(
|
|
|
|
|
[&parent, &map](DeployConfigurationFactory *factory) {
|
|
|
|
|
return factory->canRestore(parent, map);
|
|
|
|
|
});
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-04 14:48:24 +01:00
|
|
|
QList<DeployConfigurationFactory *> DeployConfigurationFactory::find(Target *parent)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2014-05-08 11:58:23 +02:00
|
|
|
return ExtensionSystem::PluginManager::getObjects<DeployConfigurationFactory>(
|
|
|
|
|
[&parent](DeployConfigurationFactory *factory) {
|
|
|
|
|
return !factory->availableCreationIds(parent).isEmpty();
|
|
|
|
|
});
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, DeployConfiguration *dc)
|
|
|
|
|
{
|
2014-05-08 11:58:23 +02:00
|
|
|
return ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>(
|
|
|
|
|
[&parent, &dc](DeployConfigurationFactory *factory) {
|
|
|
|
|
return factory->canClone(parent, dc);
|
|
|
|
|
});
|
2012-09-20 14:42:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool DeployConfigurationFactory::canHandle(Target *parent) const
|
|
|
|
|
{
|
2013-05-06 11:14:27 +02:00
|
|
|
if (!parent->project()->supportsKit(parent->kit()) || parent->project()->needsSpecialDeployment())
|
2012-04-24 15:49:09 +02:00
|
|
|
return false;
|
2012-09-03 18:31:44 +02:00
|
|
|
return DeviceTypeKitInformation::deviceTypeId(parent->kit()) == Constants::DESKTOP_DEVICE_TYPE;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|