qtprojectgeneratorfactory.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #include <algorithm>
  2. #include <iterator>
  3. #include <QScriptEngine>
  4. #include "qtprojectgeneratorfactory.h"
  5. #include "settings.h"
  6. #include "symbian/symbiandefines.h"
  7. #include "symbian/symbianqtprojectgenerator.h"
  8. #include "maemo5/maemo5defines.h"
  9. #include "maemo5/maemo5qtprojectgenerator.h"
  10. #include "rcsymbian/rcsymbianqtprojectgenerator.h"
  11. #include "rcmaemo5/rcmaemo5qtprojectgenerator.h"
  12. /**
  13. * This anonymous namespace is the configuration
  14. * for the "static plugin" types that implement platform specific
  15. * project generation.
  16. */
  17. namespace
  18. {
  19. IQtProjectGenerator * LocalSymbianPGCtor(QString /* platformId */,
  20. GeneratorOutputView & outputView,
  21. QObject * parent)
  22. {
  23. IQtProjectGenerator
  24. * rv = new SymbianQtProjectGenerator(outputView,
  25. parent);
  26. return rv;
  27. }
  28. IQtProjectGenerator * LocalMaemo5PGCtor(QString /* platformId */,
  29. GeneratorOutputView & outputView,
  30. QObject * parent)
  31. {
  32. IQtProjectGenerator
  33. * rv = new Maemo5QtProjectGenerator(outputView,
  34. parent);
  35. return rv;
  36. }
  37. IQtProjectGenerator * RemoteSymbianPGCtor(QString platformId,
  38. GeneratorOutputView & outputView,
  39. QObject * parent)
  40. {
  41. IQtProjectGenerator
  42. * rv = new RcSymbianQtProjectGenerator(platformId,
  43. outputView,
  44. parent);
  45. return rv;
  46. }
  47. IQtProjectGenerator * RemoteMaemo5PGCtor(QString platformId,
  48. GeneratorOutputView & outputView,
  49. QObject * parent)
  50. {
  51. IQtProjectGenerator
  52. * rv = new RcMaemo5QtProjectGenerator(platformId,
  53. outputView,
  54. parent);
  55. return rv;
  56. }
  57. typedef IQtProjectGenerator * (PGCtor)(QString, GeneratorOutputView &, QObject *);
  58. const PlatformInfo PLATFORMINFOS[] = {
  59. { SYMBIAN_PLATFORMNAME,
  60. SYMBIAN_SHORTDESC,
  61. DYN_BUILDTARGET SYMBIAN_PLATFORMNAME,
  62. true,
  63. reinterpret_cast<void*>(&LocalSymbianPGCtor)
  64. }
  65. #if 0 // Disable local maemo compilation
  66. ,
  67. { MAEMO5_PLATFORMNAME,
  68. MAEMO5_SHORTDESC,
  69. DYN_BUILDTARGET MAEMO5_PLATFORMNAME,
  70. false,
  71. reinterpret_cast<void*>(&LocalMaemo5PGCtor)
  72. }
  73. #endif
  74. };
  75. }
  76. QtProjectGeneratorFactory::QtProjectGeneratorFactory()
  77. {
  78. using namespace std;
  79. // Local, hardwired compilation environments
  80. copy(PLATFORMINFOS,
  81. PLATFORMINFOS + sizeof(PLATFORMINFOS)/sizeof(PlatformInfo),
  82. back_inserter(m_supportedPlatforms));
  83. // Check for remote, dynamically configured compilation environments
  84. QScriptEngine
  85. scriptEngine;
  86. Settings::OsDescMap
  87. osDescMap = Settings::RcOSes(scriptEngine);
  88. if (osDescMap.size() == 0)
  89. return;
  90. Settings::OsQtPairList
  91. osQtPairs = Settings::RcOsQtPairs(scriptEngine);
  92. foreach (Settings::OsQtPair osQtPair, osQtPairs)
  93. {
  94. PlatformInfo
  95. pi;
  96. if (osQtPair.m_os.indexOf("s60_") == 0)
  97. {
  98. pi.m_opaque = reinterpret_cast<void*>(&RemoteSymbianPGCtor);
  99. }
  100. else if (osQtPair.m_os.indexOf("maemo5") == 0)
  101. {
  102. pi.m_opaque = reinterpret_cast<void*>(&RemoteMaemo5PGCtor);
  103. }
  104. else
  105. {
  106. continue;
  107. }
  108. pi.m_platformName = "RC %1, Qt %2";
  109. pi.m_platformName = pi.m_platformName.arg(osQtPair.m_os, osQtPair.m_qt);
  110. pi.m_platformName = pi.m_platformName.replace('_', '.');
  111. pi.m_shortDescription = "Remote Compiling for ";
  112. pi.m_shortDescription += osDescMap[osQtPair.m_os];
  113. pi.m_shortDescription += " with Qt v";
  114. pi.m_shortDescription += osQtPair.m_qt;
  115. pi.m_platformName = pi.m_platformName.replace('_', '.');
  116. // The platform id shall be the prefix with the wccParams concatenated
  117. // to it.
  118. pi.m_platformId = "%1%2";
  119. pi.m_platformId = pi.m_platformId.arg(DYN_BUILDTARGET,
  120. osQtPair.wccParams());
  121. pi.m_isDefault = false;
  122. m_supportedPlatforms.push_back(pi);
  123. }
  124. }
  125. QList<PlatformInfo> QtProjectGeneratorFactory::supportedPlatforms() const
  126. {
  127. QList<PlatformInfo>
  128. rv(m_supportedPlatforms);
  129. return rv;
  130. }
  131. IQtProjectGenerator *
  132. QtProjectGeneratorFactory::createProjectGenerator(const QString & platformId,
  133. GeneratorOutputView & outputView,
  134. QObject * parent) const
  135. {
  136. IQtProjectGenerator
  137. * rv = NULL;
  138. QList<PlatformInfo>::const_iterator
  139. it = m_supportedPlatforms.begin(),
  140. end = m_supportedPlatforms.end();
  141. for (; it != end; ++it)
  142. {
  143. if (it->m_platformId == platformId)
  144. {
  145. PGCtor
  146. * ctor = reinterpret_cast<PGCtor*>(it->m_opaque);
  147. rv = (*ctor)(platformId,
  148. outputView,
  149. parent);
  150. break;
  151. }
  152. }
  153. return rv;
  154. }