Commit 53d41cb8 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Project file evaluation: Take sysroot into account.

Task-number: QTCREATORBUG-1858
Reviewed-by: Oswald Buddenhagen
parent 29ad8a45
......@@ -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();
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment