Commit 9fa9c227 authored by Tobias Hunger's avatar Tobias Hunger

Qbs: Add QbsDeployConfigurationFactory

Add QbsDeployConfigurationFactory and mark the QbsProject to not
work with the default deployment for Desktop projects.

Change-Id: I9230d5017b475d53cf13e86b4a073c248fedfaf0
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent d389c45b
/****************************************************************************
**
** 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.
**
****************************************************************************/
#include "qbsdeployconfigurationfactory.h"
#include "qbsinstallstep.h"
#include "qbsproject.h"
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/target.h>
namespace QbsProjectManager {
namespace Internal {
// --------------------------------------------------------------------
// Helpers:
// --------------------------------------------------------------------
static QString genericQbsDisplayName() {
return QCoreApplication::translate("Qbs", "Qbs Install");
}
static Core::Id genericQbsDeployConfigurationId()
{
return Core::Id("Qbs.Deploy");
}
// --------------------------------------------------------------------
// QbsDeployConfiguration:
// --------------------------------------------------------------------
QbsDeployConfiguration::QbsDeployConfiguration(ProjectExplorer::Target *target, const Core::Id id) :
ProjectExplorer::DeployConfiguration(target, id)
{ }
QbsDeployConfiguration::QbsDeployConfiguration(ProjectExplorer::Target *target,
ProjectExplorer::DeployConfiguration *source) :
ProjectExplorer::DeployConfiguration(target, source)
{
cloneSteps(source);
}
// --------------------------------------------------------------------
// QbsDeployConfigurationFactory:
// --------------------------------------------------------------------
QbsDeployConfigurationFactory::QbsDeployConfigurationFactory(QObject *parent) :
ProjectExplorer::DeployConfigurationFactory(parent)
{
setObjectName(QLatin1String("QbsDeployConfiguration"));
}
QList<Core::Id> QbsDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
{
QList<Core::Id> ids;
if (qobject_cast<QbsProject *>(parent->project()))
ids << genericQbsDeployConfigurationId();
return ids;
}
QString QbsDeployConfigurationFactory::displayNameForId(const Core::Id id) const
{
if (id == genericQbsDeployConfigurationId())
return genericQbsDisplayName();
return QString();
}
bool QbsDeployConfigurationFactory::canCreate(ProjectExplorer::Target *parent,
const Core::Id id) const
{
return availableCreationIds(parent).contains(id);
}
ProjectExplorer::DeployConfiguration
*QbsDeployConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
{
Q_ASSERT(canCreate(parent, id));
QbsDeployConfiguration *dc = new QbsDeployConfiguration(parent, id);
dc->setDisplayName(genericQbsDisplayName());
dc->stepList()->insertStep(0, new QbsInstallStep(dc->stepList()));
return dc;
}
bool QbsDeployConfigurationFactory::canRestore(ProjectExplorer::Target *parent,
const QVariantMap &map) const
{
return canCreate(parent, ProjectExplorer::idFromMap(map));
}
ProjectExplorer::DeployConfiguration
*QbsDeployConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
{
if (!canRestore(parent, map))
return 0;
Core::Id id = ProjectExplorer::idFromMap(map);
QbsDeployConfiguration *dc = new QbsDeployConfiguration(parent, id);
if (!dc->fromMap(map)) {
delete dc;
return 0;
}
return dc;
}
ProjectExplorer::DeployConfiguration
*QbsDeployConfigurationFactory::clone(ProjectExplorer::Target *parent,
ProjectExplorer::DeployConfiguration *product)
{
if (!canClone(parent, product))
return 0;
return new QbsDeployConfiguration(parent, qobject_cast<QbsDeployConfiguration *>(product));
}
} // namespace Internal
} // namespace QbsProjectManager
/****************************************************************************
**
** 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 QBSDEPLOYCONFIGURATIONFACTORY_H
#define QBSDEPLOYCONFIGURATIONFACTORY_H
#include <projectexplorer/deployconfiguration.h>
namespace QbsProjectManager {
namespace Internal {
class QbsDeployConfigurationFactory;
class QbsDeployConfiguration : public ProjectExplorer::DeployConfiguration
{
Q_OBJECT
private:
QbsDeployConfiguration(ProjectExplorer::Target *target, const Core::Id id);
QbsDeployConfiguration(ProjectExplorer::Target *target,
ProjectExplorer::DeployConfiguration *source);
friend class QbsDeployConfigurationFactory;
};
class QbsDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory
{
Q_OBJECT
public:
explicit QbsDeployConfigurationFactory(QObject *parent = 0);
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
QString displayNameForId(const Core::Id id) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
ProjectExplorer::DeployConfiguration *product);
};
} // namespace Internal
} // namespace QbsProjectManager
#endif // QBSDEPLOYCONFIGURATIONFACTORY_H
......@@ -239,6 +239,11 @@ const qbs::ProjectData *QbsProject::qbsProjectData() const
return m_rootProjectNode->projectData();
}
bool QbsProject::needsSpecialDeployment() const
{
return true;
}
void QbsProject::handleQbsParsingDone(bool success)
{
QTC_ASSERT(m_qbsSetupProjectJob, return);
......
......@@ -94,6 +94,8 @@ public:
const qbs::Project *qbsProject() const;
const qbs::ProjectData *qbsProjectData() const;
bool needsSpecialDeployment() const;
public slots:
void invalidate();
void parseCurrentBuildConfiguration();
......
......@@ -18,6 +18,7 @@ HEADERS = \
qbsbuildconfigurationwidget.h \
qbsbuildstep.h \
qbscleanstep.h \
qbsdeployconfigurationfactory.h \
qbsinstallstep.h \
qbslogsink.h \
qbsnodes.h \
......@@ -35,6 +36,7 @@ SOURCES = \
qbsbuildconfigurationwidget.cpp \
qbsbuildstep.cpp \
qbscleanstep.cpp \
qbsdeployconfigurationfactory.cpp \
qbsinstallstep.cpp \
qbslogsink.cpp \
qbsnodes.cpp \
......
......@@ -59,6 +59,8 @@ QtcPlugin {
"qbscleanstep.cpp",
"qbscleanstep.h",
"qbscleanstepconfigwidget.ui",
"qbsdeployconfigurationfactory.cpp",
"qbsdeployconfigurationfactory.h",
"qbsinstallstep.cpp",
"qbsinstallstep.h",
"qbsinstallstepconfigwidget.ui",
......
......@@ -32,6 +32,7 @@
#include "qbsbuildconfiguration.h"
#include "qbsbuildstep.h"
#include "qbscleanstep.h"
#include "qbsdeployconfigurationfactory.h"
#include "qbsinstallstep.h"
#include "qbsproject.h"
#include "qbsprojectmanager.h"
......@@ -83,6 +84,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString *
addAutoReleasedObject(new QbsBuildStepFactory);
addAutoReleasedObject(new QbsCleanStepFactory);
addAutoReleasedObject(new QbsInstallStepFactory);
addAutoReleasedObject(new QbsDeployConfigurationFactory);
//menus
// Build Menu:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment