hybridplugin.cpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #include <QDebug>
  2. #include <QDir>
  3. #include "hybridplugin.h"
  4. #include "iqtprojectgenerator.h"
  5. HybridPlugin::HybridPlugin()
  6. {
  7. }
  8. HybridPlugin::~HybridPlugin()
  9. {
  10. }
  11. const QString& HybridPlugin::name() const
  12. {
  13. return m_name;
  14. }
  15. void HybridPlugin::setName(QString name)
  16. {
  17. m_name = name;
  18. }
  19. const QString& HybridPlugin::version() const
  20. {
  21. return m_version;
  22. }
  23. void HybridPlugin::setVersion(QString version)
  24. {
  25. m_version = version;
  26. }
  27. const QList< QSharedPointer<HybridPluginPlatform> >& HybridPlugin::platforms() const
  28. {
  29. return m_platforms;
  30. }
  31. void HybridPlugin::addPlatform(QSharedPointer<HybridPluginPlatform> platform)
  32. {
  33. m_platforms.append(platform);
  34. }
  35. void HybridPlugin::selectPlatform(QSharedPointer<HybridPluginPlatform> platform)
  36. {
  37. m_selectedPlatform = platform;
  38. }
  39. QSharedPointer<HybridPluginPlatform> HybridPlugin::selectedPlatform() const
  40. {
  41. return m_selectedPlatform;
  42. }
  43. QSharedPointer<HybridPluginPlatform> HybridPlugin::conformingVersion(const PlatformType& type)
  44. {
  45. // Clear previous selection
  46. m_selectedPlatform = QSharedPointer<HybridPluginPlatform>();
  47. qDebug() << "Selecting platform for plugin " << name() << ", platform "
  48. << type.m_platformName << type.m_platformVersion
  49. << ", Qt " << type.m_qtVersion;
  50. // Check for libs
  51. foreach(QSharedPointer<HybridPluginPlatform> platform, m_platforms)
  52. {
  53. if (platform->name().toLower() == type.m_platformName.toLower() &&
  54. platform->format() == HybridPluginPlatform::Library)
  55. {
  56. // In lib format, let's stick to strict versions both in
  57. // the platform and in Qt
  58. if (platform->version() == type.m_platformVersion &&
  59. platform->qtVersion() == type.m_qtVersion)
  60. {
  61. m_selectedPlatform = platform;
  62. }
  63. }
  64. }
  65. // Check for sources
  66. if (!m_selectedPlatform)
  67. {
  68. foreach(QSharedPointer<HybridPluginPlatform> platform, m_platforms)
  69. {
  70. if (platform->name().toLower() == type.m_platformName.toLower() &&
  71. platform->format() == HybridPluginPlatform::Source)
  72. {
  73. // With source we're for now going to assume there are no
  74. // restrictions in Qt or platform versions
  75. m_selectedPlatform = platform;
  76. }
  77. }
  78. }
  79. if (m_selectedPlatform)
  80. {
  81. qDebug() << (m_selectedPlatform->format() == HybridPluginPlatform::Source ? "source" : "lib");
  82. qDebug() << (m_selectedPlatform->configuration() == HybridPluginPlatform::Release ? "release" : "debug");
  83. }
  84. else
  85. {
  86. qDebug() << "No suitable platform found";
  87. }
  88. // Null default representing no compatible versions
  89. return m_selectedPlatform;
  90. }
  91. QString HybridPlugin::symbianDeploymentString(bool isRemotelyCompiled)
  92. {
  93. // Precompiled library
  94. // Indentation weirdness to make generated project source more readable
  95. //@name@api-dll = \" \\\"$$PWD/mw/@name@/@url@\\\" - \\\"!:\\sys\\bin\\@name@api.dll\\\"\"\n\
  96. //@name@api-qtplugin.pkg_postrules += @name@api-dll\n\
  97. //@name@api-qtplugin.pkg_postrules += @name@api-plugin\n\
  98. //@name@api-qtplugin.sources = mw\\@name@\\@url@\n\
  99. //@name@api-qtplugin.path = \\resource\\qt\\plugins\\hybridplugins\n\
  100. //@name@api-stub.sources = mw\\@name@\\qmakepluginstubs\\@name@api.qtplugin\n\
  101. //@name@api-stub.path = \\resource\\qt\\plugins\\hybridplugins\n\
  102. //@name@api-plg = \" \\\"$$PWD/qmakepluginstubs/@name@api.qtplugin\\\" - \\\"!:\\resource\\qt\\plugins\\hybridplugins\\@name@api.qtplugin\\\"\"\n\
  103. //@name@api-qtplugin.pkg_postrules += @name@api-plg\n\
  104. //DEPLOYMENT += @name@api-stub\n\
  105. //@name@api-qtplugin.sources = mw/@name@/@url@\n\
  106. //@name@api-qtplugin.path = \\resource\\qt\\plugins\\hybridplugins\n\
  107. //@name@api-qtplugin.pkg_prerules += @name@api-plugin\n\
  108. //@name@api-qtplugin.sources = qmakepluginstubs\\@name@api.qtplugin\n\
  109. //@name@api-qtplugin.path = \\resource\\qt\\plugins\\hybridplugins\n\
  110. //
  111. //@name@api-dll = \" \\\"$$PWD/mw/@name@/@url@\\\" - \\\"!:\\sys\\bin\\@name@api.dll\\\"\"\n\
  112. //@name@api-plugin = \" \\\"$$PWD/qmakepluginstubs\\@name@api.qtplugin\\\" - \\\"!:\\resource\\qt\\plugins\\hybridplugins\\@name@api.qtplugin\\\"\"\n\
  113. //@name@api-dll = \" \\\"C:\\wcc\\build\\src\\_\\mw\\@name@\\@url@\\\" - \\\"!:\\sys\\bin\\@name@api.dll\\\"\"\n\
  114. //@name@api-plugin = \" \\\"C:\\wcc\\build\\src\\_\\qmakepluginstubs\\@name@api.qtplugin\\\" - \\\"!:\\resource\\qt\\plugins\\hybridplugins\\@name@api.qtplugin\\\"\"\n\
  115. static const QString remoteLibraryDeployment = "\n\
  116. @name@api-dll = \" \\\"C:\\wcc\\build\\src\\_\\mw\\@name@\\@url@\\\" - \\\"!:\\sys\\bin\\@name@api.dll\\\"\"\n\
  117. @name@api-plugin = \" \\\"C:\\wcc\\build\\src\\_\\qmakepluginstubs\\@name@api.qtplugin\\\" - \\\"!:\\resource\\qt\\plugins\\hybridplugins\\@name@api.qtplugin\\\"\"\n\
  118. @name@api-qtplugin.pkg_prerules += @name@api-dll\n\
  119. @name@api-qtplugin.pkg_prerules += @name@api-plugin\n\
  120. DEPLOYMENT += @name@api-qtplugin\n";
  121. static const QString localLibraryDeployment = "\n\
  122. @name@api-dll = \" \\\"$$PWD/mw/@name@/@url@\\\" - \\\"!:\\sys\\bin\\@name@api.dll\\\"\"\n\
  123. @name@api-qtplugin.pkg_postrules += @name@api-dll\n\
  124. @name@api-qtplugin.sources = qmakepluginstubs\\@name@api.qtplugin\n\
  125. @name@api-qtplugin.path = \\resource\\qt\\plugins\\hybridplugins\n\
  126. DEPLOYMENT += @name@api-qtplugin\n";
  127. // Library compiled from sources
  128. static const QString sourceDeployment = "\n\
  129. @name@api-dll.sources = \\epoc32\\release\\$(PLATFORM)\\$(CFG)\\@name@api.dll\n\
  130. @name@api-dll.path = \\sys\\bin\n\
  131. DEPLOYMENT += @name@api-dll\n\
  132. @name@api-qtplugin.sources = mw\\@name@\\qmakepluginstubs\\@name@api.qtplugin\n\
  133. @name@api-qtplugin.path = \\resource\\qt\\plugins\\hybridplugins\n\
  134. DEPLOYMENT += @name@api-qtplugin\n";
  135. if (m_selectedPlatform->format() == HybridPluginPlatform::Library) {
  136. if (isRemotelyCompiled) {
  137. return QString(remoteLibraryDeployment)
  138. .replace("@name@", name())
  139. .replace("@url@", m_selectedPlatform->url());
  140. } else {
  141. return QString(localLibraryDeployment)
  142. .replace("@name@", name())
  143. .replace("@url@", m_selectedPlatform->url());
  144. }
  145. } else if (m_selectedPlatform->format() == HybridPluginPlatform::Source) {
  146. return QString(sourceDeployment).replace("@name@", name());
  147. } else {
  148. return "";
  149. }
  150. }