tizendeploypackagecreationstep.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**************************************************************************
  2. **
  3. ** Copyright (c) 2013 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 "tizenconfigurations.h"
  30. #include "tizendeploypackagecreationstep.h"
  31. #include "tizendeploypackagecreationconfigwidget.h"
  32. #include "tizenmanager.h"
  33. #include <projectexplorer/buildsteplist.h>
  34. #include <projectexplorer/deployconfiguration.h>
  35. #include <projectexplorer/target.h>
  36. #include <projectexplorer/buildconfiguration.h>
  37. #include <projectexplorer/kitinformation.h>
  38. #include <qt4projectmanager/qt4project.h>
  39. #include <qt4projectmanager/qt4nodes.h>
  40. #include <utils/hostosinfo.h>
  41. #include <QDebug>
  42. #include <QDir>
  43. using namespace Tizen::Internal;
  44. const Core::Id TizenDeployPackageCreationStep::Id = Core::Id("Qt4ProjectManager.TizenDeployPackageCreationStep");
  45. TizenDeployPackageCreationStep::TizenDeployPackageCreationStep(ProjectExplorer::BuildStepList *bsl)
  46. : BuildStep(bsl, Id),m_nativePackagingProcess(0)
  47. {
  48. const QString name = tr("Create package(tpk)");
  49. setDefaultDisplayName(name);
  50. setDisplayName(name);
  51. }
  52. bool TizenDeployPackageCreationStep::init()
  53. {
  54. return true;
  55. }
  56. ProjectExplorer::BuildStepConfigWidget *TizenDeployPackageCreationStep::createConfigWidget()
  57. {
  58. TizenDeployPackageCreationConfigWidget *configWidget = new TizenDeployPackageCreationConfigWidget();
  59. TizenConfig tc = TizenConfigurations::instance()->tizenConfig();
  60. QString passwd = tc.m_authorCertificatePassword;
  61. passwd.fill(QChar::fromAscii('*'),passwd.size());
  62. configWidget->setAdditionalSummaryText(QString::fromLatin1("%1 --sign-author-key %2 --sign-author-pwd %3 in %4")
  63. .arg(tc.m_nativePackagingLocation.toString())
  64. .arg(tc.m_authorCertificateLocation.toString())
  65. .arg(passwd)
  66. .arg(TizenManager::commandLineBuildPath(target()).toString()));
  67. return configWidget;
  68. }
  69. TizenDeployPackageCreationStep::TizenDeployPackageCreationStep(ProjectExplorer::BuildStepList *bc, TizenDeployPackageCreationStep *other)
  70. : BuildStep(bc, other)
  71. { }
  72. void TizenDeployPackageCreationStep::run(QFutureInterface<bool> &fi)
  73. {
  74. emit addOutput(tr("Creating package."), BuildStep::MessageOutput);
  75. QProcess tmp;
  76. m_nativePackagingProcess = &tmp;
  77. connect(m_nativePackagingProcess,SIGNAL(readyRead()),SLOT(updateProcessOutput()));
  78. m_nativePackagingProcess->setWorkingDirectory(TizenManager::commandLineBuildPath(target()).toString());
  79. QStringList arguments;
  80. TizenConfig tc = TizenConfigurations::instance()->tizenConfig();
  81. arguments << QLatin1String("--sign-author-key") << tc.m_authorCertificateLocation.toString();
  82. arguments << QLatin1String("--sign-author-pwd") << tc.m_authorCertificatePassword;
  83. m_nativePackagingProcess->start(tc.m_nativePackagingLocation.toString(), arguments);
  84. if(!m_nativePackagingProcess->waitForStarted(5000) || !m_nativePackagingProcess->waitForFinished(360000)) {
  85. addOutput(tr("Can't start %1.").arg(tc.m_nativePackagingLocation.toString()), BuildStep::ErrorOutput);
  86. fi.reportResult(false);
  87. m_nativePackagingProcess = 0;
  88. return;
  89. }
  90. if (m_nativePackagingProcess->exitCode() != 0) {
  91. emit addOutput(tr("Error while creating package."), BuildStep::ErrorOutput);
  92. fi.reportResult(false);
  93. } else {
  94. emit addOutput(tr("Package Created."), BuildStep::MessageOutput);
  95. fi.reportResult(true);
  96. }
  97. m_nativePackagingProcess = 0;
  98. }
  99. void TizenDeployPackageCreationStep::updateProcessOutput()
  100. {
  101. if (!m_nativePackagingProcess)
  102. return;
  103. QByteArray nativePackagingOutput = m_nativePackagingProcess->readAll();
  104. if (nativePackagingOutput.trimmed().isEmpty())
  105. return;
  106. emit addOutput(QString::fromLocal8Bit(nativePackagingOutput.constData(), nativePackagingOutput.size()), BuildStep::NormalOutput, BuildStep::DontAppendNewline);
  107. }
  108. void TizenDeployPackageCreationStep::cancel()
  109. {
  110. if (!m_nativePackagingProcess)
  111. return;
  112. if (m_nativePackagingProcess->state() == QProcess::Running) {
  113. m_nativePackagingProcess->terminate();
  114. }
  115. }