From 53d41cb84b76d4fc3e9ddb21cc7efd22e1a54495 Mon Sep 17 00:00:00 2001 From: Christian Kandeler <christian.kandeler@nokia.com> Date: Wed, 5 Jan 2011 17:56:49 +0100 Subject: [PATCH] Project file evaluation: Take sysroot into account. Task-number: QTCREATORBUG-1858 Reviewed-by: Oswald Buddenhagen --- src/plugins/qt4projectmanager/qt4project.cpp | 5 ++++- src/shared/proparser/profileevaluator.cpp | 19 +++++++++++++++---- src/shared/proparser/profileevaluator.h | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 343c6f5f7b1..9b3eccdf10a 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -921,8 +921,11 @@ ProFileReader *Qt4Project::createProFileReader(Qt4ProFileNode *qt4ProFileNode) if (activeTarget() && activeTarget()->activeBuildConfiguration()) { QtVersion *version = activeTarget()->activeBuildConfiguration()->qtVersion(); - if (version->isValid()) + if (version->isValid()) { m_proFileOption->properties = version->versionInfo(); + m_proFileOption->sysroot + = activeTarget()->activeBuildConfiguration()->toolChain()->sysroot(); + } } ProFileCacheManager::instance()->incRefCount(); diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 46124e62295..3b3771426dd 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -216,6 +216,8 @@ public: QStringList qmakeMkspecPaths() const; QStringList qmakeFeaturePaths() const; + QString sysrootify(const QString &path, const QString &baseDir) const; + int m_skipLevel; int m_loopLevel; // To report unexpected break() and next()s bool m_cumulative; @@ -1468,6 +1470,13 @@ QString ProFileEvaluator::Private::currentDirectory() const return cur->directoryName(); } +QString ProFileEvaluator::Private::sysrootify(const QString &path, const QString &baseDir) const +{ + const bool isHostSystemPath = m_option->sysroot.isEmpty() || path.startsWith(m_option->sysroot) + || path.startsWith(baseDir) || path.startsWith(m_outputDir); + return isHostSystemPath ? path : m_option->sysroot + path; +} + // The (QChar*)current->constData() constructs below avoid pointless detach() calls // FIXME: This is inefficient. Should not make new string if it is a straight subsegment static ALWAYS_INLINE void appendChar(ushort unicode, @@ -3147,7 +3156,8 @@ QStringList ProFileEvaluator::absolutePathValues( { QStringList result; foreach (const QString &el, values(variable)) { - QString absEl = IoUtils::resolvePath(baseDirectory, el); + QString absEl = IoUtils::isAbsolutePath(el) + ? d->sysrootify(el, baseDirectory) : IoUtils::resolvePath(baseDirectory, el); if (IoUtils::fileType(absEl) == IoUtils::FileIsDir) result << QDir::cleanPath(absEl); } @@ -3162,11 +3172,12 @@ QStringList ProFileEvaluator::absoluteFileValues( foreach (const QString &el, pro ? values(variable, pro) : values(variable)) { QString absEl; if (IoUtils::isAbsolutePath(el)) { - if (IoUtils::exists(el)) { - result << QDir::cleanPath(el); + const QString elWithSysroot = d->sysrootify(el, baseDirectory); + if (IoUtils::exists(elWithSysroot)) { + result << QDir::cleanPath(elWithSysroot); goto next; } - absEl = el; + absEl = elWithSysroot; } else { foreach (const QString &dir, searchDirs) { QString fn = dir + QLatin1Char('/') + el; diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h index 917a32ffbb8..5ad5f8cf868 100644 --- a/src/shared/proparser/profileevaluator.h +++ b/src/shared/proparser/profileevaluator.h @@ -173,6 +173,7 @@ struct ProFileOption QString qmakespec; QString cachefile; QHash<QString, QString> properties; + QString sysroot; enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE }; TARG_MODE target_mode; -- GitLab