tizendeploypackagecreationstep.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 "tizendebug.h"
  30. #include "tizenconfigurations.h"
  31. #include "tizendeploypackagecreationstep.h"
  32. #include "tizendeploypackagecreationconfigwidget.h"
  33. #include "tizenmanager.h"
  34. #include "processoutputhandler.h"
  35. #include <projectexplorer/buildsteplist.h>
  36. #include <projectexplorer/deployconfiguration.h>
  37. #include <projectexplorer/target.h>
  38. #include <projectexplorer/buildconfiguration.h>
  39. #include <projectexplorer/kitinformation.h>
  40. #include <qmakeprojectmanager/qmakeproject.h>
  41. #include <qmakeprojectmanager/qmakenodes.h>
  42. #include <utils/hostosinfo.h>
  43. #include <QDebug>
  44. #include <QDir>
  45. #include <QThread>
  46. using namespace Tizen::Internal;
  47. const Core::Id TizenDeployPackageCreationStep::Id = Core::Id("Qt4ProjectManager.TizenDeployPackageCreationStep");
  48. TizenDeployPackageCreationStep::TizenDeployPackageCreationStep(ProjectExplorer::BuildStepList *bsl)
  49. : BuildStep(bsl, Id)
  50. {
  51. const QString name = tr("Create package(tpk)");
  52. setDefaultDisplayName(name);
  53. setDisplayName(name);
  54. }
  55. bool TizenDeployPackageCreationStep::init()
  56. {
  57. return true;
  58. }
  59. ProjectExplorer::BuildStepConfigWidget *TizenDeployPackageCreationStep::createConfigWidget()
  60. {
  61. TizenDeployPackageCreationConfigWidget *configWidget = new TizenDeployPackageCreationConfigWidget();
  62. TizenConfig tc = TizenConfigurations::currentConfig();
  63. QString passwd = tc.authorCertificatePassword();
  64. passwd.fill(QChar::fromAscii('*'),passwd.size());
  65. configWidget->setAdditionalSummaryText(QString::fromLatin1("%1 --sign-author-key %2 --sign-author-pwd %3 in %4")
  66. .arg(tc.nativePackagingLocation().toString())
  67. .arg(tc.authorCertificateLocation().toString())
  68. .arg(passwd)
  69. .arg(TizenManager::commandLineBuildPath(target()).toString()));
  70. return configWidget;
  71. }
  72. TizenDeployPackageCreationStep::TizenDeployPackageCreationStep(ProjectExplorer::BuildStepList *bc, TizenDeployPackageCreationStep *other)
  73. : BuildStep(bc, other)
  74. { }
  75. void TizenDeployPackageCreationStep::run(QFutureInterface<bool> &fi)
  76. {
  77. emit addOutput(tr("Creating package."), BuildStep::MessageOutput);
  78. QProcess *nativePackagingProcess = new QProcess;
  79. connect(new ProcessOutputHandler(nativePackagingProcess),
  80. SIGNAL(output(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)),
  81. SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)));
  82. nativePackagingProcess->setWorkingDirectory(TizenManager::commandLineBuildPath(target()).toString());
  83. QStringList arguments;
  84. TizenConfig tc = TizenConfigurations::currentConfig();
  85. arguments << QLatin1String("--sign-author-key") << tc.authorCertificateLocation().toString();
  86. arguments << QLatin1String("--sign-author-pwd");
  87. arguments << QLatin1String("***");
  88. addOutput(tr("Starting %1 %2.").arg(tc.nativePackagingLocation().toString()).arg(arguments.join(QLatin1Char(' '))), BuildStep::MessageOutput);
  89. arguments.pop_back();
  90. arguments << tc.authorCertificatePassword();
  91. nativePackagingProcess->start(tc.nativePackagingLocation().toString(), arguments);
  92. if(!nativePackagingProcess->waitForStarted() || !nativePackagingProcess->waitForFinished(60 * 60 * 1000)) {
  93. addOutput(tr("Can't start %1.").arg(tc.nativePackagingLocation().toString()), BuildStep::ErrorOutput);
  94. fi.reportResult(false);
  95. nativePackagingProcess->deleteLater();
  96. return;
  97. }
  98. if (nativePackagingProcess->exitCode() != 0) {
  99. emit addOutput(tr("Error while creating package."), BuildStep::ErrorOutput);
  100. fi.reportResult(false);
  101. } else {
  102. emit addOutput(tr("Package Created."), BuildStep::MessageOutput);
  103. fi.reportResult(true);
  104. }
  105. //disconnect(nativePackagingProcess, 0, this, 0);
  106. nativePackagingProcess->deleteLater();
  107. }