From 9f824f416594aba1548c6e5e245cbfc97591325b Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Wed, 17 Nov 2010 10:37:11 +0100
Subject: [PATCH] Symbian: Fix pathes

Fix pathes for Nokia Qt SDK:
 * Set SBS path in one location only
 * Fix up perl path
 * Set path to CMD on windows. Both ABLD and SBSv2 actually need this.
 * Set GCC path only if the directory actually exists

These fixes allow for building both ABLD and SBSv2 based projects in
a clean environment.

Reviewed-by: Tim Jenssen
---
 .../qt4projectmanager/qt-s60/s60devices.cpp   | 25 +++++++++++++------
 .../qt4projectmanager/qtversionmanager.cpp    |  9 +++++--
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp
index ec646942b04..771888a33d3 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp
@@ -542,10 +542,23 @@ QList<ProjectExplorer::HeaderPath> S60ToolChainMixin::epocHeaderPaths() const
 
 void S60ToolChainMixin::addEpocToEnvironment(Utils::Environment *env) const
 {
+#if defined(Q_OS_WIN)
+    QString winDir = QLatin1String(qgetenv("WINDIR"));
+    if (!winDir.isEmpty())
+        env->prependOrSetPath(QDir(winDir).filePath(QLatin1String("system32")));
+#endif
+
     QDir epocDir(m_device.epocRoot);
+
     env->prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/tools"))); // e.g. make.exe
-    env->prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/gcc/bin"))); // e.g. gcc.exe
-    env->prependOrSetPath(epocDir.filePath(QLatin1String("perl/bin"))); // e.g. perl.exe (special SDK version)
+
+    if (epocDir.exists(QLatin1String("epoc32/gcc/bin")))
+        env->prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/gcc/bin"))); // e.g. cpp.exe, *NOT* gcc.exe
+    // Find perl in the special Symbian flavour:
+    if (epocDir.exists(QLatin1String("../../tools/perl/bin")))
+        env->prependOrSetPath(epocDir.filePath(QLatin1String("../../tools/perl/bin")));
+    else
+        env->prependOrSetPath(epocDir.filePath(QLatin1String("perl/bin")));
 
     addBaseToEnvironment(env);
 }
@@ -593,13 +606,9 @@ void S60ToolChainMixin::addGnuPocToEnvironment(Utils::Environment *env) const
 
 void S60ToolChainMixin::addBaseToEnvironment(Utils::Environment *env) const
 {
-    QString sbsHome(env->value(QLatin1String("SBS_HOME"))); // Do we use Raptor/SBSv2?
-    if (!sbsHome.isEmpty())
-        env->prependOrSetPath(sbsHome + QDir::separator() + QLatin1String("bin"));
-
     QString epocRootPath(m_device.epocRoot);
-    if (!epocRootPath.endsWith(QChar('/')))
-        epocRootPath.append(QChar('/'));
+    if (!epocRootPath.endsWith(QLatin1Char('/')))
+        epocRootPath.append(QLatin1Char('/'));
     env->set(QLatin1String("EPOCROOT"), QDir::toNativeSeparators(S60Devices::cleanedRootPath(epocRootPath)));
 }
 
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 5189d87feb2..031eceee840 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -1594,8 +1594,13 @@ void QtVersion::setMsvcVersion(const QString &version)
 void QtVersion::addToEnvironment(Utils::Environment &env) const
 {
     env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA")));
-    if (isBuildWithSymbianSbsV2() && !m_sbsV2Directory.isEmpty())
-        env.prependOrSetPath(m_sbsV2Directory);
+    if (isBuildWithSymbianSbsV2()) {
+        QString sbsHome(env.value(QLatin1String("SBS_HOME")));
+        if (!m_sbsV2Directory.isEmpty())
+            env.prependOrSetPath(m_sbsV2Directory);
+        else if (!sbsHome.isEmpty())
+            env.prependOrSetPath(sbsHome + QLatin1Char('/') + QLatin1String("bin"));
+    }
     env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS"));
 }
 
-- 
GitLab