tizendeployconfiguration.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**************************************************************************
  2. **
  3. ** Copyright (c) 2014 Tomasz Olszak <olszak.tomasz@gmail.com>
  4. ** Contact: http://www.qt-project.org/legal
  5. **
  6. ** This file is part of Qt Creator.
  7. **
  8. ** Commercial License Usage
  9. ** Licensees holding valid commercial Qt licenses may use this file in
  10. ** accordance with the commercial license agreement provided with the
  11. ** Software or, alternatively, in accordance with the terms contained in
  12. ** a written agreement between you and Digia. For licensing terms and
  13. ** conditions see http://qt.digia.com/licensing. For further information
  14. ** use the contact form at http://qt.digia.com/contact-us.
  15. **
  16. ** GNU Lesser General Public License Usage
  17. ** Alternatively, this file may be used under the terms of the GNU Lesser
  18. ** General Public License version 2.1 as published by the Free Software
  19. ** Foundation and appearing in the file LICENSE.LGPL included in the
  20. ** packaging of this file. Please review the following information to
  21. ** ensure the GNU Lesser General Public License version 2.1 requirements
  22. ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  23. **
  24. ** In addition, as a special exception, Digia gives you certain additional
  25. ** rights. These rights are described in the Digia Qt LGPL Exception
  26. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  27. **
  28. ****************************************************************************/
  29. #include "tizendebug.h"
  30. #include "tizendeployconfiguration.h"
  31. #include "tizenconfigurations.h"
  32. #include "tizendeploydirectorycreationstep.h"
  33. #include "tizendeploypackagecreationstep.h"
  34. #include "tizendeploypackageinstallationstep.h"
  35. #include "tizenconstants.h"
  36. #include "tizenmanager.h"
  37. #include <projectexplorer/buildsteplist.h>
  38. #include <projectexplorer/target.h>
  39. #include <projectexplorer/toolchain.h>
  40. #include <projectexplorer/buildconfiguration.h>
  41. #include <qmakeprojectmanager/qmakeproject.h>
  42. #include <qmakeprojectmanager/qmakenodes.h>
  43. #include <qtsupport/qtkitinformation.h>
  44. #include <qtsupport/qtsupportconstants.h>
  45. using namespace ProjectExplorer;
  46. namespace Tizen {
  47. namespace Internal {
  48. TizenDeployConfiguration::TizenDeployConfiguration(Target *parent, Core::Id id)
  49. : DeployConfiguration(parent, id)
  50. {
  51. setDisplayName(tr("Deploy to Tizen device"));
  52. setDefaultDisplayName(displayName());
  53. }
  54. TizenDeployConfiguration::TizenDeployConfiguration(Target *parent, DeployConfiguration *source)
  55. : DeployConfiguration(parent, source)
  56. {
  57. cloneSteps(source);
  58. }
  59. TizenDeployConfigurationFactory::TizenDeployConfigurationFactory(QObject *parent)
  60. : DeployConfigurationFactory(parent)
  61. {
  62. setObjectName(QLatin1String("TizenDeployConfigurationFactory"));
  63. }
  64. bool TizenDeployConfigurationFactory::canCreate(Target *parent, const Core::Id id) const
  65. {
  66. return availableCreationIds(parent).contains(id);
  67. }
  68. DeployConfiguration *TizenDeployConfigurationFactory::create(Target *parent, const Core::Id id)
  69. {
  70. qCDebug(QTC_TIZEN);
  71. TizenDeployConfiguration *dc = new TizenDeployConfiguration(parent, id);
  72. if (!dc)
  73. return 0;
  74. dc->stepList()->insertStep(0, new TizenDeployDirectoryCreationStep(dc->stepList()));
  75. if (id == Core::Id(TIZEN_DEPLOY_MAKE_INSTALL_CONFIGURATION_ID)) {
  76. dc->setDisplayName(tr("Make install"));
  77. dc->setDefaultDisplayName(tr("Make install"));
  78. return dc;
  79. }
  80. QmakeProjectManager::QmakeProject *project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project());
  81. if (!project) {
  82. return 0;
  83. }
  84. QmakeProjectManager::QmakeProFileNode * rootQmakeProjectNode = project->rootQmakeProjectNode();
  85. if ( rootQmakeProjectNode && rootQmakeProjectNode->projectType() == QmakeProjectManager::ApplicationTemplate
  86. && QFile::exists(TizenManager::manifestPath(parent).toString())) {
  87. dc->stepList()->insertStep(1, new TizenDeployPackageCreationStep(dc->stepList()));
  88. dc->stepList()->insertStep(2, new TizenDeployPackageInstallationStep(dc->stepList()));
  89. }
  90. return dc;
  91. }
  92. bool TizenDeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
  93. {
  94. return canCreate(parent, idFromMap(map));
  95. }
  96. DeployConfiguration *TizenDeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
  97. {
  98. if (!canRestore(parent, map))
  99. return 0;
  100. TizenDeployConfiguration *dc = new TizenDeployConfiguration(parent, idFromMap(map));
  101. if (dc->fromMap(map))
  102. return dc;
  103. delete dc;
  104. return 0;
  105. }
  106. bool TizenDeployConfigurationFactory::canClone(Target *, DeployConfiguration *source) const
  107. {
  108. return false;
  109. }
  110. DeployConfiguration *TizenDeployConfigurationFactory::clone(Target *parent, DeployConfiguration *source)
  111. {
  112. if (!canClone(parent, source))
  113. return 0;
  114. return new TizenDeployConfiguration(parent, source);
  115. }
  116. QList<Core::Id> TizenDeployConfigurationFactory::availableCreationIds(Target *parent) const
  117. {
  118. QList<Core::Id> ids;
  119. if (!qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project())) {
  120. return ids;
  121. }
  122. if (!parent->project()->supportsKit(parent->kit()))
  123. return ids;
  124. ToolChain *tc = ToolChainKitInformation::toolChain(parent->kit());
  125. if (!tc || tc->type() != QLatin1String(Constants::TIZEN_TOOLCHAIN_GCC_TYPE))
  126. return ids;
  127. if (QtSupport::QtKitInformation::qtVersion(parent->kit())->type() != QLatin1String(Constants::TIZEN_QT))
  128. return ids;
  129. ids << Core::Id(TIZEN_DEPLOY_TO_DEVICE_CONFIGURATION_ID) << Core::Id(TIZEN_DEPLOY_MAKE_INSTALL_CONFIGURATION_ID);
  130. return ids;
  131. }
  132. QString TizenDeployConfigurationFactory::displayNameForId(const Core::Id id) const
  133. {
  134. if (id == Core::Id(TIZEN_DEPLOY_MAKE_INSTALL_CONFIGURATION_ID)) {
  135. return tr("Make install configuration");
  136. } else if (id == Core::Id(TIZEN_DEPLOY_TO_DEVICE_CONFIGURATION_ID)) {
  137. return tr("Deploy to Tizen device configuration");
  138. }
  139. return QString();
  140. }
  141. bool TizenDeployConfigurationFactory::canHandle(Target *parent) const
  142. {
  143. return TizenManager::supportsTizen(parent);
  144. }
  145. } // namespace Internal
  146. } // namespace Tizen