From c8d6c400b67a8c127a5328b84aa3d49ed7a64ae8 Mon Sep 17 00:00:00 2001
From: con <qtc-committer@nokia.com>
Date: Wed, 5 Aug 2009 14:33:05 +0200
Subject: [PATCH] If no mwc path is set explicitly, still don't destroy working
 environment.

So now we use the values of the system environment as a backup
for build environment and system includes.
---
 .../qt-s60/winscwtoolchain.cpp                | 54 ++++++++++++-------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp
index ecff59d68d9..3cec7f629df 100644
--- a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp
@@ -29,6 +29,8 @@
 
 #include "winscwtoolchain.h"
 
+#include <QtDebug>
+
 using namespace ProjectExplorer;
 using namespace Qt4ProjectManager::Internal;
 
@@ -64,30 +66,42 @@ QList<HeaderPath> WINSCWToolChain::systemHeaderPaths()
 
 QStringList WINSCWToolChain::systemIncludes() const
 {
-    QStringList symIncludes = QStringList()
-        << "\\MSL\\MSL_C\\MSL_Common\\Include"
-        << "\\MSL\\MSL_C\\MSL_Win32\\Include"
-        << "\\MSL\\MSL_CMSL_X86"
-        << "\\MSL\\MSL_C++\\MSL_Common\\Include"
-        << "\\MSL\\MSL_Extras\\MSL_Common\\Include"
-        << "\\MSL\\MSL_Extras\\MSL_Win32\\Include"
-        << "\\Win32-x86 Support\\Headers\\Win32 SDK";
-    for (int i = 0; i < symIncludes.size(); ++i)
-        symIncludes[i].prepend(QString("%1\\x86Build\\Symbian_Support").arg(m_carbidePath));
-    return symIncludes;
+    if (m_carbidePath.isEmpty()) {
+        qDebug() << "no carbide path set";
+        ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
+        QString symIncludesValue = env.value("MWCSYM2INCLUDES");
+        qDebug() << "includes:" << symIncludesValue.split(";");
+        if (!symIncludesValue.isEmpty())
+            return symIncludesValue.split(";");
+    } else {
+        QStringList symIncludes = QStringList()
+            << "\\MSL\\MSL_C\\MSL_Common\\Include"
+            << "\\MSL\\MSL_C\\MSL_Win32\\Include"
+            << "\\MSL\\MSL_CMSL_X86"
+            << "\\MSL\\MSL_C++\\MSL_Common\\Include"
+            << "\\MSL\\MSL_Extras\\MSL_Common\\Include"
+            << "\\MSL\\MSL_Extras\\MSL_Win32\\Include"
+            << "\\Win32-x86 Support\\Headers\\Win32 SDK";
+        for (int i = 0; i < symIncludes.size(); ++i)
+            symIncludes[i].prepend(QString("%1\\x86Build\\Symbian_Support").arg(m_carbidePath));
+        return symIncludes;
+    }
+    return QStringList();
 }
 
 void WINSCWToolChain::addToEnvironment(ProjectExplorer::Environment &env)
 {
-    env.set("MWCSYM2INCLUDES", systemIncludes().join(";"));
-    QStringList symLibraries = QStringList()
-        << "\\Win32-x86 Support\\Libraries\\Win32 SDK"
-        << "\\Runtime\\Runtime_x86\\Runtime_Win32\\Libs";
-    for (int i = 0; i < symLibraries.size(); ++i)
-        symLibraries[i].prepend(QString("%1\\x86Build\\Symbian_Support").arg(m_carbidePath));
-    env.set("MWSYM2LIBRARIES", symLibraries.join(";"));
-    env.set("MWSYM2LIBRARYFILES", "MSL_All_MSE_Symbian_D.lib;gdi32.lib;user32.lib;kernel32.lib");
-    env.prependOrSetPath(QString("%1\\x86Build\\Symbian_Tools\\Command_Line_Tools").arg(m_carbidePath)); // compiler
+    if (!m_carbidePath.isEmpty()) {
+        env.set("MWCSYM2INCLUDES", systemIncludes().join(";"));
+        QStringList symLibraries = QStringList()
+            << "\\Win32-x86 Support\\Libraries\\Win32 SDK"
+            << "\\Runtime\\Runtime_x86\\Runtime_Win32\\Libs";
+        for (int i = 0; i < symLibraries.size(); ++i)
+            symLibraries[i].prepend(QString("%1\\x86Build\\Symbian_Support").arg(m_carbidePath));
+        env.set("MWSYM2LIBRARIES", symLibraries.join(";"));
+        env.set("MWSYM2LIBRARYFILES", "MSL_All_MSE_Symbian_D.lib;gdi32.lib;user32.lib;kernel32.lib");
+        env.prependOrSetPath(QString("%1\\x86Build\\Symbian_Tools\\Command_Line_Tools").arg(m_carbidePath)); // compiler
+    }
     env.prependOrSetPath(QString("%1\\epoc32\\tools").arg(m_deviceRoot)); // e.g. make.exe
     env.prependOrSetPath(QString("%1\\epoc32\\gcc\\bin").arg(m_deviceRoot)); // e.g. gcc.exe
     env.set("EPOCDEVICE", QString("%1:%2").arg(m_deviceId, m_deviceName));
-- 
GitLab