summaryrefslogtreecommitdiff
path: root/src/libs/utils/environment.cpp
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@nokia.com>2012-04-30 19:01:26 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-05-02 12:21:01 +0200
commitf3d49692eb61579e5fe519c4ac61089eec5cc547 (patch)
treeae33d1ae0eb56313d4e6309290da3086f44e4394 /src/libs/utils/environment.cpp
parent2c1c89fa352ce57e31d76455791debea6d8e3545 (diff)
downloadqt-creator-f3d49692eb61579e5fe519c4ac61089eec5cc547.tar.gz
Sanitize environment for buildsteps
Remove the paths that qtcreator.sh adds to LD_LIBRARY_PATH. The linker uses LD_LIBRARY_PATH as a fall-back to find libraries, leading to confussing error messages. Task-number: QTCREATORBUG-7285 Change-Id: I1a2ba86e39f4c417b192d4faea4714165fdb4aac Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src/libs/utils/environment.cpp')
-rw-r--r--src/libs/utils/environment.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libs/utils/environment.cpp b/src/libs/utils/environment.cpp
index d6d0124d00..b31d767da2 100644
--- a/src/libs/utils/environment.cpp
+++ b/src/libs/utils/environment.cpp
@@ -35,6 +35,30 @@
#include <QDir>
#include <QProcess>
#include <QString>
+#include <QCoreApplication>
+
+class SystemEnvironment : public Utils::Environment
+{
+public:
+ SystemEnvironment()
+ : Environment(QProcess::systemEnvironment())
+ {
+#ifdef Q_OS_LINUX
+ QString ldLibraryPath = value(QLatin1String("LD_LIBRARY_PATH"));
+ QDir lib(QCoreApplication::applicationDirPath());
+ lib.cd("../lib");
+ QString toReplace = lib.path();
+ lib.cd("qtcreator");
+ toReplace.append(QLatin1String(":"));
+ toReplace.append(lib.path());
+
+ if (ldLibraryPath.startsWith(toReplace))
+ set(QLatin1String("LD_LIBRARY_PATH"), ldLibraryPath.remove(0, toReplace.length()));
+#endif
+ }
+};
+
+Q_GLOBAL_STATIC(SystemEnvironment, staticSystemEnvironment)
namespace Utils {
@@ -198,7 +222,7 @@ void Environment::prependOrSetLibrarySearchPath(const QString &value)
Environment Environment::systemEnvironment()
{
- return Environment(QProcess::systemEnvironment());
+ return *staticSystemEnvironment();
}
void Environment::clear()