main.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the examples of the Qt Toolkit.
  8. **
  9. ** $QT_BEGIN_LICENSE:LGPL$
  10. ** Commercial Usage
  11. ** Licensees holding valid Qt Commercial licenses may use this file in
  12. ** accordance with the Qt Commercial License Agreement provided with the
  13. ** Software or, alternatively, in accordance with the terms contained in
  14. ** a written agreement between you and Nokia.
  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, Nokia gives you certain additional
  25. ** rights. These rights are described in the Nokia Qt LGPL Exception
  26. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  27. **
  28. ** GNU General Public License Usage
  29. ** Alternatively, this file may be used under the terms of the GNU
  30. ** General Public License version 3.0 as published by the Free Software
  31. ** Foundation and appearing in the file LICENSE.GPL included in the
  32. ** packaging of this file. Please review the following information to
  33. ** ensure the GNU General Public License version 3.0 requirements will be
  34. ** met: http://www.gnu.org/copyleft/gpl.html.
  35. **
  36. ** If you have questions regarding the use of this file, please contact
  37. ** Nokia at qt-info@nokia.com.
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #include <iostream>
  42. #include <QApplication>
  43. #include <QDebug>
  44. #include <QFile>
  45. #include <QTextStream>
  46. #include "consolegenerator.h"
  47. #include "remotegenerator.h"
  48. #include "mainwindow.h"
  49. #include "argumentparser.h"
  50. #include "settings.h"
  51. #include "iqtprojectgenerator.h"
  52. #include "qtprojectgeneratorfactory.h"
  53. #include "generatorconsoleoutput.h"
  54. // NOTE: Includes unfinished features, commiting to main repository
  55. // because of change in project personnel
  56. using namespace std;
  57. QStringList ErrorsForTarget(const QString & platformName,
  58. GeneratorTarget generatorTarget)
  59. {
  60. GeneratorConsoleOutput
  61. gco;
  62. QtProjectGeneratorFactory
  63. generatorFactory;
  64. IQtProjectGenerator
  65. * generator = generatorFactory.createProjectGenerator(platformName,
  66. gco);
  67. QStringList
  68. rv = generator->errorsForTarget(generatorTarget);
  69. delete generator;
  70. return rv;
  71. }
  72. int main(int argc, char *argv[])
  73. {
  74. QApplication app(argc, argv);
  75. if (argc < 2)
  76. {
  77. // GUI version
  78. MainWindow window;
  79. window.show();
  80. return app.exec();
  81. }
  82. else
  83. {
  84. // CLI version
  85. QTextStream cin(stdin, QIODevice::ReadOnly);
  86. QTextStream cout(stdout, QIODevice::WriteOnly);
  87. QTextStream cerr(stderr, QIODevice::WriteOnly);
  88. ArgumentParser parser(argc, argv);
  89. /* OBS
  90. // Check settings, and check that the file and build action are given
  91. QStringList errors = Settings::errorsForTarget(BUILD);
  92. */
  93. QStringList errors = ErrorsForTarget(parser.getPlatform(),
  94. BUILD);
  95. if (!errors.isEmpty())
  96. {
  97. foreach (QString error, errors)
  98. {
  99. cerr << "Error: " << error << "\n";
  100. }
  101. }
  102. else
  103. {
  104. if (parser.getFileType() == ArgumentParser::Invalid)
  105. {
  106. cerr << "Error: Valid file for processing was not given!\n";
  107. }
  108. else if (parser.getTarget() == NO_TARGET)
  109. {
  110. cerr << "Error: No build action was defined!\n";
  111. }
  112. else
  113. {
  114. // ConsoleGenerator can give feedback in console or in a simple dialog
  115. ConsoleGenerator generator(parser);
  116. return app.exec();
  117. }
  118. }
  119. }
  120. return 0;
  121. }