forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Oswald Buddenhagen
parent
2c1c89fa35
commit
f3d49692eb
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user