qmake/generators/symbian/initprojectdeploy_symbian.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp	Mon May 03 13:17:34 2010 +0300
@@ -46,15 +46,21 @@
 #include <qsettings.h>
 #include <qdebug.h>
 
-#define PLUGIN_STUB_DIR "qmakepluginstubs"
-#define SYSBIN_DIR "/sys/bin"
 // Included from tools/shared
 #include <symbian/epocroot.h>
 
+#define SYSBIN_DIR "/sys/bin"
+
 #define SUFFIX_DLL "dll"
 #define SUFFIX_EXE "exe"
 #define SUFFIX_QTPLUGIN "qtplugin"
 
+static QString fixPathToEpocOS(const QString &src)
+{
+    QString ret = Option::fixPathToTargetOS(src);
+    return ret.replace('/', '\\');
+}
+
 static bool isPlugin(const QFileInfo& info, const QString& devicePath)
 {
     // Libraries are plugins if deployment path is something else than
@@ -85,7 +91,7 @@
                              QStringList& generatedDirs,
                              QStringList& generatedFiles)
 {
-    QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR "/"));
+    QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR));
     if (!generatedDirs.contains(PLUGIN_STUB_DIR))
         generatedDirs << PLUGIN_STUB_DIR;
     // Plugin stubs must have different name from the actual plugins, because
@@ -104,7 +110,7 @@
     }
     QFileInfo stubInfo(stubFile);
     deploymentList.append(CopyItem(Option::fixPathToLocalOS(stubInfo.absoluteFilePath()),
-                                   Option::fixPathToLocalOS(devicePath + "/" + stubInfo.fileName())));
+                                   fixPathToEpocOS(devicePath + "/" + stubInfo.fileName())));
 }
 
 QString generate_uid(const QString& target)
@@ -168,30 +174,29 @@
 
     foreach(QString item, project->values("DEPLOYMENT")) {
         QString devicePath = project->first(item + ".path");
-        QString devicePathwDrive = devicePath;
+        QString devicePathWithoutDrive = devicePath;
 
         bool devicePathHasDriveLetter = false;
         if (devicePath.size() > 1) {
             devicePathHasDriveLetter = devicePath.at(1) == QLatin1Char(':');
         }
 
-        //QTP: Sometime devicePath can contain disk but APP_RESOURCE_DIR not
-        //convert devicepath to correct format and delete drive letter
+        // Sometimes devicePath can contain disk but APP_RESOURCE_DIR does not,
+        // so remove the drive letter for comparison purposes.
         if (devicePathHasDriveLetter)
         {
-            devicePathwDrive.remove(0,2);
+            devicePathWithoutDrive.remove(0,2);
         }
         if (!deployBinaries
-                && !devicePathwDrive.isEmpty()
-                && (0 == devicePathwDrive.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive)
-                    || 0 == devicePathwDrive.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) {
+                && !devicePathWithoutDrive.isEmpty()
+                && (0 == devicePathWithoutDrive.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive)
+                    || 0 == devicePathWithoutDrive.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) {
             // Do not deploy resources in emulator builds, as that seems to cause conflicts
             // If there is ever a real need to deploy pre-built resources for emulator,
             // BLD_INF_RULES.prj_exports can be used as a workaround.
             continue;
         }
 
-
         if (devicePath.isEmpty() || devicePath == QLatin1String(".")) {
             devicePath = targetPath;
         }
@@ -199,38 +204,27 @@
         else if (!(devicePath.at(0) == QLatin1Char('/')
                    || devicePath.at(0) == QLatin1Char('\\')
                    || devicePathHasDriveLetter)) {
-            // create output path
+            // Create output path
             devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('/') + devicePath));
         } else {
-            if (0 == platform.compare(QLatin1String("winscw"), Qt::CaseInsensitive)) {
+            if (!platform.compare(QLatin1String(EMULATOR_DEPLOYMENT_PLATFORM))) {
                 if (devicePathHasDriveLetter) {
                     devicePath = epocRoot() + "epoc32/winscw/" + devicePath.remove(1, 1);
                 } else {
                     devicePath = epocRoot() + "epoc32/winscw/c" + devicePath;
                 }
             } else {
-                //The logic of the calling the initProjectDeploySymbian function depends only 
-                //from devicePathHasDriveLetter in pro files.
-                //:QTP:QTPROD-92 Deployment of plugins requires WINSCW build before ARM build
                 if (!devicePathHasDriveLetter) {
-                    if (targetPathHasDriveLetter) {
+                    if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) {
+                        //For plugin deployment under ARM no needed drive letter
+                        devicePath = epocRoot() + "epoc32/data/z" + devicePath;
+                    } else if (targetPathHasDriveLetter) {
                         // Drive letter needed if targetpath contains one and it is not already in
-                        if ( 0 == platform.compare(QLatin1String("armv5"), Qt::CaseInsensitive) ) {
-                         //For plugin deployment under ARM no needed drive letter
-                         devicePath = epocRoot() + "epoc32/data/z" + devicePath;
-                        } else {
-                         devicePath = deploymentDrive + devicePath;
-                       }
-                    } else {
-                        // Only deployment for ARM need full path for the deployment
-                        if (0 == platform.compare(QLatin1String("armv5"), Qt::CaseInsensitive) ) {
-                         devicePath = epocRoot() + "epoc32/data/z" + devicePath;
-                        } 
+                        devicePath = deploymentDrive + devicePath;
                     }
-
                 } else {
                     //it is necessary to delete drive letter for ARM deployment
-                    if (!platform.compare("armv5")) {
+                    if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) {
                         devicePath.remove(0,2);
                         devicePath = epocRoot() + "epoc32/data/z" + devicePath;
                     }
@@ -262,13 +256,7 @@
                 dirSearch = true;
             } else {
                 if (info.exists() || source.indexOf('*') != -1) {
-//QTP-Prod: Temporary solution due Option::fixPathToLocalOS. This function always replaces / to \ for Windows 
-//in the source. Changes fixPathToLocalOS requires more investigation and testing.
-#if defined(Q_OS_WIN32)
-                    nameFilter = source.split('\\').last();
-#else
-                    nameFilter = source.split('/').last();
-#endif
+                    nameFilter = source.split(QDir::separator()).last();
                     searchPath = info.absolutePath();
                 } else {
                     // Entry was not found. That is ok if it is a binary, since those do not necessarily yet exist.
@@ -276,13 +264,19 @@
                     if (isBinary(info)) {
                         if (deployBinaries) {
                             // Executables and libraries are deployed to \sys\bin
-                            QFileInfo releasePath(epocRoot() + "epoc32/release/" + platform + "/" + build + "/");
+                            QFileInfo targetPath(epocRoot() + "epoc32/release/" + platform + "/" + build + "/");
                             if(devicePathHasDriveLetter) {
-                                deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "/" + info.fileName(), false, true),
-                                                               Option::fixPathToLocalOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/") + info.fileName())));
+                                deploymentList.append(CopyItem(
+                                    Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(),
+                                    false, true),
+                                    fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/")
+                                    + info.fileName())));
                             } else {
-                                deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "/" + info.fileName(), false, true),
-                                                               Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") + info.fileName())));
+                                deploymentList.append(CopyItem(
+                                    Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(),
+                                    false, true),
+                                    fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/")
+                                    + info.fileName())));
                             }
                         }
                         if (isPlugin(info, devicePath)) {
@@ -293,7 +287,7 @@
                         // Generate deployment even if file doesn't exist, as this may be the case
                         // when generating .pkg files.
                         deploymentList.append(CopyItem(Option::fixPathToLocalOS(info.absoluteFilePath()),
-                                                       Option::fixPathToLocalOS(devicePath + "/" + info.fileName())));
+                                                       fixPathToEpocOS(devicePath + "/" + info.fileName())));
                         continue;
                     }
                 }
@@ -315,32 +309,29 @@
                         // This deploys pre-built plugins. Other pre-built binaries will deploy normally,
                         // as they have SYSBIN_DIR target path.
                         if (deployBinaries) {
-                            deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
-                                                           Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") + iterator.fileName())));
+                            if (devicePathHasDriveLetter) {
+                                deploymentList.append(CopyItem(
+                                    Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
+                                    fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/")
+                                    + iterator.fileName())));
+                            } else {
+                                deploymentList.append(CopyItem(
+                                    Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
+                                    fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/")
+                                    + iterator.fileName())));
+                            }
                         }
-                        createPluginStub(info, devicePath + "/" + absoluteItemPath.right(diffSize), deploymentList, generatedDirs, generatedFiles);
+                        createPluginStub(info, devicePath + "/" + absoluteItemPath.right(diffSize),
+                            deploymentList, generatedDirs, generatedFiles);
                         continue;
                     } else {
-                        deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
-                                                       Option::fixPathToLocalOS(devicePath + "/" + absoluteItemPath.right(diffSize) + "/" + iterator.fileName())));
+                        deploymentList.append(CopyItem(
+                            Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
+                            fixPathToEpocOS(devicePath + "/" + absoluteItemPath.right(diffSize)
+                            + "/" + iterator.fileName())));
                     }
                 }
             }
         }
     }
 }
-
-//:QTP:QTPROD-92 Deployment of plugins requires WINSCW build before ARM build
-void writeSbsDeploymentList(const DeploymentList& depList, QTextStream& t)
-{
-    for (int i = 0; i < depList.size(); ++i) {
-        t << "START EXTENSION qt/qmake_emulator_deployment" << endl;
-        QString fromItem = depList.at(i).from;
-        QString toItem = depList.at(i).to;
-        fromItem.replace("\\", "/");
-        toItem.replace("\\", "/");
-        t << "OPTION DEPLOY_SOURCE " << fromItem << endl;
-        t << "OPTION DEPLOY_TARGET " << toItem << endl;
-        t << "END" << endl;
-    }
-}