From d3e0ffef0ff4cfa2b6c977865a504e70e7de08ad Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 31 Oct 2011 16:23:35 +0000 Subject: [PATCH] Add embedded linux target ... and required factories. Change-Id: Id8a0e7a5a83d3c05e70d61d5023401be5e201c6c Reviewed-by: Daniel Teske --- .../qt-desktop/qt4desktoptargetfactory.h | 2 +- src/plugins/qtsupport/baseqtversion.cpp | 1 - .../remotelinux/embeddedlinuxtarget.cpp | 103 ++++++++++ src/plugins/remotelinux/embeddedlinuxtarget.h | 67 +++++++ .../embeddedlinuxtargetfactory.cpp | 178 ++++++++++++++++++ .../remotelinux/embeddedlinuxtargetfactory.h | 71 +++++++ .../remotelinux/images/embeddedtarget.png | Bin 0 -> 1050 bytes src/plugins/remotelinux/remotelinux.pro | 6 + src/plugins/remotelinux/remotelinux.qrc | 5 + .../remotelinuxdeployconfigurationfactory.h | 18 +- src/plugins/remotelinux/remotelinuxplugin.cpp | 2 + 11 files changed, 441 insertions(+), 12 deletions(-) create mode 100644 src/plugins/remotelinux/embeddedlinuxtarget.cpp create mode 100644 src/plugins/remotelinux/embeddedlinuxtarget.h create mode 100644 src/plugins/remotelinux/embeddedlinuxtargetfactory.cpp create mode 100644 src/plugins/remotelinux/embeddedlinuxtargetfactory.h create mode 100644 src/plugins/remotelinux/images/embeddedtarget.png create mode 100644 src/plugins/remotelinux/remotelinux.qrc diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.h b/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.h index 42d5d88c95a..7eb4fb45217 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.h +++ b/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.h @@ -60,9 +60,9 @@ public: bool importEnabled, QList importInfos); QString buildNameForId(const QString &id) const; QSet targetFeatures(const QString &id) const; + ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id); ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id, const QList &infos); - }; } } diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 9e1a1bb4cd2..8e33dbd564b 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -1199,7 +1199,6 @@ QString BaseQtVersion::qtCorePath(const QHash &versionInfo, con else if (file.endsWith(QLatin1String(".dll")) || file.endsWith(QString::fromLatin1(".so.") + versionString) || file.endsWith(QLatin1Char('.') + versionString + QLatin1String(".dylib"))) - return info.absoluteFilePath(); } } diff --git a/src/plugins/remotelinux/embeddedlinuxtarget.cpp b/src/plugins/remotelinux/embeddedlinuxtarget.cpp new file mode 100644 index 00000000000..22f3782a649 --- /dev/null +++ b/src/plugins/remotelinux/embeddedlinuxtarget.cpp @@ -0,0 +1,103 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "embeddedlinuxtarget.h" + +#include "remotelinux_constants.h" +#include "remotelinuxrunconfiguration.h" + +#include +#include +#include +#include + +#include + +namespace RemoteLinux { +namespace Internal { + +EmbeddedLinuxTarget::EmbeddedLinuxTarget(Qt4ProjectManager::Qt4Project *parent, const QString &id) : + Qt4ProjectManager::Qt4BaseTarget(parent, id), + m_buildConfigurationFactory(new Qt4ProjectManager::Qt4BuildConfigurationFactory) +{ + setDisplayName(tr("Embedded Linux")); +} + +EmbeddedLinuxTarget::~EmbeddedLinuxTarget() +{ + delete m_buildConfigurationFactory; +} + +ProjectExplorer::IBuildConfigurationFactory *EmbeddedLinuxTarget::buildConfigurationFactory() const +{ + return m_buildConfigurationFactory; +} + +QList EmbeddedLinuxTarget::runConfigurationsForNode(ProjectExplorer::Node *n) +{ + QList result; + foreach (ProjectExplorer::RunConfiguration *rc, runConfigurations()) + if (RemoteLinuxRunConfiguration *qt4c = qobject_cast(rc)) + if (qt4c->proFilePath() == n->path()) + result << rc; + return result; +} + +void EmbeddedLinuxTarget::createApplicationProFiles() +{ + removeUnconfiguredCustomExectutableRunConfigurations(); + + // We use the list twice + QList profiles = qt4Project()->applicationProFiles(); + QStringList pathes; + foreach (Qt4ProjectManager::Qt4ProFileNode *pro, profiles) + pathes.append(pro->path()); + + foreach (ProjectExplorer::RunConfiguration *rc, runConfigurations()) { + if (RemoteLinuxRunConfiguration *qt4rc = qobject_cast(rc)) + pathes.removeAll(qt4rc->proFilePath()); + } + + // Only add new runconfigurations if there are none. + foreach (const QString &path, pathes) { + RemoteLinuxRunConfiguration *qt4rc = + new RemoteLinuxRunConfiguration(this,RemoteLinuxRunConfiguration::Id, path); + addRunConfiguration(qt4rc); + } + + // Oh still none? Add a custom executable runconfiguration + if (runConfigurations().isEmpty()) + addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(this)); +} + +} // namespace Internal +} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/embeddedlinuxtarget.h b/src/plugins/remotelinux/embeddedlinuxtarget.h new file mode 100644 index 00000000000..181a9b5b07f --- /dev/null +++ b/src/plugins/remotelinux/embeddedlinuxtarget.h @@ -0,0 +1,67 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef EMBEDDEDLINUXTARGET_H +#define EMBEDDEDLINUXTARGET_H + +#include +#include + +namespace RemoteLinux { +namespace Internal { + +class EmbeddedLinuxTargetFactory; + +class EmbeddedLinuxTarget : public Qt4ProjectManager::Qt4BaseTarget +{ + Q_OBJECT + +public: + EmbeddedLinuxTarget(Qt4ProjectManager::Qt4Project *parent, const QString &id); + ~EmbeddedLinuxTarget(); + + ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const; + + void createApplicationProFiles(); + + QList runConfigurationsForNode(ProjectExplorer::Node *n); + +private: + Qt4ProjectManager::Qt4BuildConfigurationFactory *m_buildConfigurationFactory; + + friend class EmbeddedLinuxTargetFactory; +}; + +} // namespace Internal +} // namespace RemoteLinux + +#endif // EMBEDDEDLINUXTARGET_H diff --git a/src/plugins/remotelinux/embeddedlinuxtargetfactory.cpp b/src/plugins/remotelinux/embeddedlinuxtargetfactory.cpp new file mode 100644 index 00000000000..0304b4a3ad1 --- /dev/null +++ b/src/plugins/remotelinux/embeddedlinuxtargetfactory.cpp @@ -0,0 +1,178 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "embeddedlinuxtargetfactory.h" + +#include "remotelinuxdeployconfiguration.h" +#include "remotelinuxdeployconfigurationfactory.h" +#include "embeddedlinuxtarget.h" +#include "remotelinux_constants.h" + +#include + +#include +#include +#include + +#include + +#include + +namespace RemoteLinux { +namespace Internal { + +EmbeddedLinuxTargetFactory::EmbeddedLinuxTargetFactory(QObject *parent) : + Qt4ProjectManager::Qt4BaseTargetFactory(parent) +{ } + +EmbeddedLinuxTargetFactory::~EmbeddedLinuxTargetFactory() +{ } + +QIcon EmbeddedLinuxTargetFactory::iconForId(const QString &id) const +{ + if (id == QLatin1String(Constants::EMBEDDED_LINUX_TARGET_ID)) + return QIcon(":/remotelinux/images/embeddedtarget.png"); + return QIcon(); +} + +QString EmbeddedLinuxTargetFactory::buildNameForId(const QString &id) const +{ + if (supportsTargetId(id)) + return tr("embedded"); + return QString(); +} + +QSet EmbeddedLinuxTargetFactory::targetFeatures(const QString & /*id*/) const +{ + QSet features; + features << Qt4ProjectManager::Constants::MOBILE_TARGETFEATURE_ID; + features << Qt4ProjectManager::Constants::SHADOWBUILD_TARGETFEATURE_ID; + + return features; +} + +QStringList EmbeddedLinuxTargetFactory::supportedTargetIds(ProjectExplorer::Project *project) const +{ + Q_UNUSED(project); + return QStringList() << RemoteLinux::Constants::EMBEDDED_LINUX_TARGET_ID; +} + +bool EmbeddedLinuxTargetFactory::supportsTargetId(const QString &id) const +{ + return id == RemoteLinux::Constants::EMBEDDED_LINUX_TARGET_ID; +} + +QString EmbeddedLinuxTargetFactory::displayNameForId(const QString &id) const +{ + if (id == RemoteLinux::Constants::EMBEDDED_LINUX_TARGET_ID) + return tr("Embedded Linux"); + return QString(); +} + +bool EmbeddedLinuxTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const +{ + return canCreate(parent, ProjectExplorer::idFromMap(map)); +} + +ProjectExplorer::Target *EmbeddedLinuxTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map) +{ + Q_ASSERT(canRestore(parent, map)); + + EmbeddedLinuxTarget *t = new EmbeddedLinuxTarget(static_cast(parent), + Constants::EMBEDDED_LINUX_TARGET_ID); + if (t->fromMap(map)) + return t; + + delete t; + return 0; +} + +bool EmbeddedLinuxTargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const +{ + Qt4ProjectManager::Qt4Project *project = qobject_cast(parent); + if (!project) + return false; + + return supportsTargetId(id); +} + + +ProjectExplorer::Target *EmbeddedLinuxTargetFactory::create(ProjectExplorer::Project *parent, + const QString &id) +{ + if (!canCreate(parent, id)) + return 0; + + QList knownVersions = + QtSupport::QtVersionManager::instance()->versionsForTargetId(id); + if (knownVersions.isEmpty()) + return 0; + + QtSupport::BaseQtVersion *qtVersion = knownVersions.first(); + QtSupport::BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); + + QList infos; + infos.append(Qt4ProjectManager::BuildConfigurationInfo(qtVersion, config, QString(), QString())); + infos.append(Qt4ProjectManager::BuildConfigurationInfo(qtVersion, + config ^ QtSupport::BaseQtVersion::DebugBuild, + QString(), QString())); + + return create(parent, id, infos); +} + +ProjectExplorer::Target *EmbeddedLinuxTargetFactory::create(ProjectExplorer::Project *parent, + const QString &id, + const QList &infos) +{ + if (!canCreate(parent, id) || infos.isEmpty()) + return 0; + + EmbeddedLinuxTarget *t = new EmbeddedLinuxTarget(static_cast(parent), id); + + foreach (const Qt4ProjectManager::BuildConfigurationInfo &info, infos) + t->addQt4BuildConfiguration(msgBuildConfigurationName(info), QString(), + info.version, info.buildConfig, + info.additionalArguments, info.directory, info.importing); + + t->addDeployConfiguration( + t->createDeployConfiguration( + RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId())); + + t->createApplicationProFiles(); + + if (t->runConfigurations().isEmpty()) + t->addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(t)); + return t; +} + +} // namespace Internal +} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/embeddedlinuxtargetfactory.h b/src/plugins/remotelinux/embeddedlinuxtargetfactory.h new file mode 100644 index 00000000000..74a74ef7d5a --- /dev/null +++ b/src/plugins/remotelinux/embeddedlinuxtargetfactory.h @@ -0,0 +1,71 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef EMBEDDEDLINUXTARGETFACTORY_H +#define EMBEDDEDLINUXTARGETFACTORY_H + +#include + +namespace RemoteLinux { +namespace Internal { + +class EmbeddedLinuxTargetFactory : public Qt4ProjectManager::Qt4BaseTargetFactory +{ + Q_OBJECT + +public: + explicit EmbeddedLinuxTargetFactory(QObject *parent = 0); + ~EmbeddedLinuxTargetFactory(); + + QIcon iconForId(const QString &id) const; + QString buildNameForId(const QString &id) const; + + QSet targetFeatures(const QString &id) const; + + QStringList supportedTargetIds(ProjectExplorer::Project *project) const; + bool supportsTargetId(const QString &id) const; + + QString displayNameForId(const QString &id) const; + + bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const; + ProjectExplorer::Target *restore(ProjectExplorer::Project *parent, const QVariantMap &map); + + bool canCreate(ProjectExplorer::Project *parent, const QString &id) const; + ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id); + ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id, + const QList &infos); +}; + +} // namespace Internal +} // namespace RemoteLinux + +#endif // EMBEDDEDLINUXTARGETFACTORY_H diff --git a/src/plugins/remotelinux/images/embeddedtarget.png b/src/plugins/remotelinux/images/embeddedtarget.png new file mode 100644 index 0000000000000000000000000000000000000000..93a092ab13dfecfe099db859a6f56bcbed44a92a GIT binary patch literal 1050 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}k|nMYCBgY=CFO}lsSJ)O z`AMk?p1FzXsX?iUDV2pMQ*9U+nD=%qMxz6xrYtZe3aLbiG7n>JhT-d=8H8x*15 zc6Duu_5GUrXWq#zR4d$+E%wzl>hLsWEh zbU|q;tGT(kfn2}*mBP(8TmJs7wXm{!blaVWq2q+*{5>_iU)B8=E;H50ZsBMvGO3_idd$muvJ+SDg7{+~&^QaqQ>K0Lh+x{~Hb;c4pULdT`?FV>6AVbBc3$ z-{znCx9pOD$bHpitCZ&&^Cquio>b(Z%-~XDu99F;H1FZXyUVo&TI;J8XSr{2>3U#n z#PCR9>hW_EKimAjcviSs&|&3C_Dj{D1Tq92K1L=qY~{0GC9wDjgVdL242A|p$tGHi zoGP5bF5D6xj31PwO8>ck>Wfuc#D0LY_2F)V<|zz{j7oi-X|5~T5;jjep*H^#XDHJF z!-0M;A}YEv-r7J!OeM37}cK6U>3||>G8jHfMc4&nhDH24w+9G zJ;Wvioc8Mx6f=6fmdPc>W!~yb^?D5Jd}A3ICNBCmk5xF*A-O0rX_8vbgZ~~0jAzmn zCMrfLu`ctBI@7weRw4BOBZq9?l39`rCl9f4PfS-8=xd$8uCa6{kHd=pObs_KI#n+8 zNc^-(CqmEh)PX(PKXe!hgj%>fqSl{ozOX1+PsQ@#oXsppvm&lc&}RIg_xzDR!;x=V zMlJ%Eq?ME#|A{V|&p1I%(LH{e!h3edt|LA#?cDa?3O&_$CjYoAtJhrJmo*!Iv!-RF zKEKLSpd3_Z9v*mb!^W1F12w1pCKfX-%2(G+a9Gv&X`g`1v#Rya zYMdo6bfsB8{PxZ4OWS@~ZvM)vS*AB`R*DJFWxR9ySAOa4*c-QRN1yJTG57SuH~P#K z)-rtdw>Iv6_Pr_onw>`ZFV30I*Q%W{i7>MBJY7C-Juh4H{O&MYTie=$tBU-J6C-D< z94l6{ubXtfv5R@FUjvJQ&8z0-=G2L%EDk49M3!4|PU5O%cs75{>1F!*`unHy?SCq~ zV_IeG$3JT(TMC)9{5tE>^y}u$o7%s_F2{@PJG=b6xVSiTr&WNx*y$sSSav + + images/embeddedtarget.png + + diff --git a/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h b/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h index c06f97148a9..115ba13c71a 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h +++ b/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h @@ -44,16 +44,14 @@ class RemoteLinuxDeployConfigurationFactory : public ProjectExplorer::DeployConf public: explicit RemoteLinuxDeployConfigurationFactory(QObject *parent = 0); - virtual QStringList availableCreationIds(ProjectExplorer::Target *parent) const; - virtual QString displayNameForId(const QString &id) const; - virtual bool canCreate(ProjectExplorer::Target *parent, const QString &id) const; - virtual ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const QString &id); - virtual bool canRestore(ProjectExplorer::Target *parent, - const QVariantMap &map) const; - virtual ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, - const QVariantMap &map); - virtual ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent, - ProjectExplorer::DeployConfiguration *product); + QStringList availableCreationIds(ProjectExplorer::Target *parent) const; + QString displayNameForId(const QString &id) const; + bool canCreate(ProjectExplorer::Target *parent, const QString &id) const; + ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const QString &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); static QString genericDeployConfigurationId(); }; diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index 1fe931afe3d..75d4762f602 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -33,6 +33,7 @@ #include "remotelinuxplugin.h" #include "embeddedlinuxqtversionfactory.h" +#include "embeddedlinuxtargetfactory.h" #include "deployablefile.h" #include "genericlinuxdeviceconfigurationfactory.h" #include "genericremotelinuxdeploystepfactory.h" @@ -78,6 +79,7 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments, addAutoReleasedObject(new RemoteLinuxDeployConfigurationFactory); addAutoReleasedObject(new GenericRemoteLinuxDeployStepFactory); + addAutoReleasedObject(new EmbeddedLinuxTargetFactory); addAutoReleasedObject(new EmbeddedLinuxQtVersionFactory); qRegisterMetaType("RemoteLinux::DeployableFile");