summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2016-10-21 20:23:07 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2016-11-01 17:34:29 +0000
commit1589ce3ce855833a50b4e12c86f2b9b5a83d7b02 (patch)
treeeef06ccbd022e6184e38000135cff19c35fcfd15 /src/plugins
parentc42b12c98e1b27ac7146c31fdcdbe53915cab2c8 (diff)
downloadqt-creator-1589ce3ce855833a50b4e12c86f2b9b5a83d7b02.tar.gz
chuck sysroot handling out of ProFileEvaluator
qmake doesn't do anything with sysroots at this level, so this code plain does not belong here. sysrootification is used when resolving INCLUDEPATH, which is emulating compiler behavior. this is done by higher-level code. Task-number: QTCREATORBUG-11944 Change-Id: Ia25f0b6ef713e9809d974e3f3e49ba308b8c933f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp31
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.h3
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp12
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.h10
-rw-r--r--src/plugins/qtsupport/baseqtversion.cpp2
-rw-r--r--src/plugins/qtsupport/profilereader.cpp2
-rw-r--r--src/plugins/qtsupport/profilereader.h2
-rw-r--r--src/plugins/qtsupport/qtversionfactory.cpp2
8 files changed, 48 insertions, 16 deletions
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index 0390f8ef6b..a7d2cbc2e2 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -66,6 +66,7 @@
#include <utils/theme/theme.h>
#include <proparser/prowriter.h>
#include <proparser/qmakevfs.h>
+#include <proparser/ioutils.h>
#include <QApplication>
#include <QDebug>
@@ -80,6 +81,7 @@
using namespace Core;
using namespace ProjectExplorer;
using namespace Utils;
+using namespace QMakeInternal;
// Static cached data in struct QmakeNodeStaticData providing information and icons
// for file types and the project. Do some magic via qAddPostRoutine()
@@ -195,9 +197,10 @@ public:
QString projectDir;
FileName projectFilePath;
QString buildDirectory;
+ QString sysroot;
QtSupport::ProFileReader *readerExact;
QtSupport::ProFileReader *readerCumulative;
- ProFileGlobals *qmakeGlobals;
+ QMakeGlobals *qmakeGlobals;
QMakeVfs *qmakeVfs;
};
@@ -1773,6 +1776,7 @@ EvalInput QmakeProFileNode::evalInput() const
input.projectDir = m_projectDir;
input.projectFilePath = m_projectFilePath;
input.buildDirectory = buildDir();
+ input.sysroot = m_project->qmakeSysroot();
input.readerExact = m_readerExact;
input.readerCumulative = m_readerCumulative;
input.qmakeGlobals = m_project->qmakeGlobals();
@@ -1937,7 +1941,8 @@ EvalResult *QmakeProFileNode::evaluate(const EvalInput &input)
// update other variables
result->newVarValues[DefinesVar] = input.readerExact->values(QLatin1String("DEFINES"));
- result->newVarValues[IncludePathVar] = includePaths(input.readerExact, input.buildDirectory, input.projectDir);
+ result->newVarValues[IncludePathVar] = includePaths(input.readerExact, input.sysroot,
+ input.buildDirectory, input.projectDir);
result->newVarValues[CppFlagsVar] = input.readerExact->values(QLatin1String("QMAKE_CXXFLAGS"));
result->newVarValues[CppHeaderVar] = fileListForVar(input.readerExact, input.readerCumulative,
QLatin1String("HEADERS"), input.projectDir, input.buildDirectory);
@@ -2298,7 +2303,24 @@ QString QmakeProFileNode::mocDirPath(QtSupport::ProFileReader *reader, const QSt
return path;
}
-QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader, const QString &buildDir, const QString &projectDir)
+QString QmakeProFileNode::sysrootify(const QString &path, const QString &sysroot,
+ const QString &baseDir, const QString &outputDir)
+{
+#ifdef Q_OS_WIN
+ Qt::CaseSensitivity cs = Qt::CaseInsensitive;
+#else
+ Qt::CaseSensitivity cs = Qt::CaseSensitive;
+#endif
+ if (sysroot.isEmpty() || path.startsWith(sysroot, cs)
+ || path.startsWith(baseDir, cs) || path.startsWith(outputDir, cs)) {
+ return path;
+ }
+ QString sysrooted = QDir::cleanPath(sysroot + path);
+ return !IoUtils::exists(sysrooted) ? path : sysrooted;
+}
+
+QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader, const QString &sysroot,
+ const QString &buildDir, const QString &projectDir)
{
QStringList paths;
foreach (const QString &cxxflags, reader->values(QLatin1String("QMAKE_CXXFLAGS"))) {
@@ -2306,7 +2328,8 @@ QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader, con
paths.append(cxxflags.mid(2));
}
- paths.append(reader->fixifiedValues(QLatin1String("INCLUDEPATH"), projectDir, buildDir));
+ foreach (const QString &el, reader->fixifiedValues(QLatin1String("INCLUDEPATH"), projectDir, buildDir))
+ paths << sysrootify(el, sysroot, projectDir, buildDir);
// paths already contains moc dir and ui dir, due to corrrectly parsing uic.prf and moc.prf
// except if those directories don't exist at the time of parsing
// thus we add those directories manually (without checking for existence)
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.h b/src/plugins/qmakeprojectmanager/qmakenodes.h
index 18462eef7e..819c604a82 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.h
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.h
@@ -393,7 +393,8 @@ private:
const QString &varName, const QString &projectDir, const QString &buildDir);
static QString uiDirPath(QtSupport::ProFileReader *reader, const QString &buildDir);
static QString mocDirPath(QtSupport::ProFileReader *reader, const QString &buildDir);
- static QStringList includePaths(QtSupport::ProFileReader *reader, const QString &buildDir, const QString &projectDir);
+ static QString sysrootify(const QString &path, const QString &sysroot, const QString &baseDir, const QString &outputDir);
+ static QStringList includePaths(QtSupport::ProFileReader *reader, const QString &sysroot, const QString &buildDir, const QString &projectDir);
static QStringList libDirectories(QtSupport::ProFileReader *reader);
static Utils::FileNameList subDirsPaths(QtSupport::ProFileReader *reader, const QString &projectDir, QStringList *subProjectsNotToDeploy, QStringList *errors);
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index 11af890763..fec983b645 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -891,7 +891,7 @@ void QmakeProject::proFileParseError(const QString &errorMessage)
QtSupport::ProFileReader *QmakeProject::createProFileReader(const QmakeProFileNode *qmakeProFileNode, QmakeBuildConfiguration *bc)
{
if (!m_qmakeGlobals) {
- m_qmakeGlobals = new ProFileGlobals;
+ m_qmakeGlobals = new QMakeGlobals;
m_qmakeGlobalsRefCnt = 0;
Kit *k;
@@ -912,7 +912,7 @@ QtSupport::ProFileReader *QmakeProject::createProFileReader(const QmakeProFileNo
}
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k);
- QString systemRoot = SysRootKitInformation::hasSysRoot(k)
+ m_qmakeSysroot = SysRootKitInformation::hasSysRoot(k)
? SysRootKitInformation::sysRoot(k).toString() : QString();
if (qtVersion && qtVersion->isValid()) {
@@ -920,7 +920,6 @@ QtSupport::ProFileReader *QmakeProject::createProFileReader(const QmakeProFileNo
m_qmakeGlobals->setProperties(qtVersion->versionInfo());
}
m_qmakeGlobals->setDirectories(rootProjectNode()->sourceDir(), rootProjectNode()->buildDir());
- m_qmakeGlobals->sysroot = systemRoot;
Environment::const_iterator eit = env.constBegin(), eend = env.constEnd();
for (; eit != eend; ++eit)
@@ -953,7 +952,7 @@ QtSupport::ProFileReader *QmakeProject::createProFileReader(const QmakeProFileNo
return reader;
}
-ProFileGlobals *QmakeProject::qmakeGlobals()
+QMakeGlobals *QmakeProject::qmakeGlobals()
{
return m_qmakeGlobals;
}
@@ -963,6 +962,11 @@ QMakeVfs *QmakeProject::qmakeVfs()
return m_qmakeVfs;
}
+QString QmakeProject::qmakeSysroot()
+{
+ return m_qmakeSysroot;
+}
+
void QmakeProject::destroyProFileReader(QtSupport::ProFileReader *reader)
{
delete reader;
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.h b/src/plugins/qmakeprojectmanager/qmakeproject.h
index 2816b6e571..9a2ecb8aad 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.h
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.h
@@ -38,7 +38,7 @@
#include <QFuture>
QT_BEGIN_NAMESPACE
-class ProFileGlobals;
+class QMakeGlobals;
class QMakeVfs;
QT_END_NAMESPACE
@@ -91,10 +91,12 @@ public:
/// \internal
QtSupport::ProFileReader *createProFileReader(const QmakeProFileNode *qmakeProFileNode, QmakeBuildConfiguration *bc = 0);
/// \internal
- ProFileGlobals *qmakeGlobals();
+ QMakeGlobals *qmakeGlobals();
/// \internal
QMakeVfs *qmakeVfs();
/// \internal
+ QString qmakeSysroot();
+ /// \internal
void destroyProFileReader(QtSupport::ProFileReader *reader);
/// \internal
@@ -188,9 +190,11 @@ private:
QMakeVfs *m_qmakeVfs = nullptr;
// cached data during project rescan
- ProFileGlobals *m_qmakeGlobals = nullptr;
+ QMakeGlobals *m_qmakeGlobals = nullptr;
int m_qmakeGlobalsRefCnt = 0;
+ QString m_qmakeSysroot;
+
QTimer m_asyncUpdateTimer;
QFutureInterface<void> *m_asyncUpdateFutureInterface = nullptr;
int m_pendingEvaluateFuturesCount = 0;
diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp
index fdebbfe4f3..459e07dd07 100644
--- a/src/plugins/qtsupport/baseqtversion.cpp
+++ b/src/plugins/qtsupport/baseqtversion.cpp
@@ -1009,7 +1009,7 @@ void BaseQtVersion::ensureMkSpecParsed() const
return;
QMakeVfs vfs;
- ProFileGlobals option;
+ QMakeGlobals option;
option.setProperties(versionInfo());
option.environment = qmakeRunEnvironment().toProcessEnvironment();
ProMessageHandler msgHandler(true);
diff --git a/src/plugins/qtsupport/profilereader.cpp b/src/plugins/qtsupport/profilereader.cpp
index 7bbf0b5110..4c48f2a204 100644
--- a/src/plugins/qtsupport/profilereader.cpp
+++ b/src/plugins/qtsupport/profilereader.cpp
@@ -74,7 +74,7 @@ void ProMessageHandler::fileMessage(int type, const QString &msg)
}
-ProFileReader::ProFileReader(ProFileGlobals *option, QMakeVfs *vfs)
+ProFileReader::ProFileReader(QMakeGlobals *option, QMakeVfs *vfs)
: QMakeParser(ProFileCacheManager::instance()->cache(), vfs, this)
, ProFileEvaluator(option, this, vfs, this)
, m_ignoreLevel(0)
diff --git a/src/plugins/qtsupport/profilereader.h b/src/plugins/qtsupport/profilereader.h
index 97b2f8b851..5e53d2d2dc 100644
--- a/src/plugins/qtsupport/profilereader.h
+++ b/src/plugins/qtsupport/profilereader.h
@@ -68,7 +68,7 @@ class QTSUPPORT_EXPORT ProFileReader : public ProMessageHandler, public QMakePar
Q_OBJECT
public:
- ProFileReader(ProFileGlobals *option, QMakeVfs *vfs);
+ ProFileReader(QMakeGlobals *option, QMakeVfs *vfs);
~ProFileReader();
void setCumulative(bool on);
diff --git a/src/plugins/qtsupport/qtversionfactory.cpp b/src/plugins/qtsupport/qtversionfactory.cpp
index 0c32f3665c..f9b57c05d7 100644
--- a/src/plugins/qtsupport/qtversionfactory.cpp
+++ b/src/plugins/qtsupport/qtversionfactory.cpp
@@ -54,7 +54,7 @@ BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileN
Utils::FileName mkspec = BaseQtVersion::mkspecFromVersionInfo(versionInfo);
QMakeVfs vfs;
- ProFileGlobals globals;
+ QMakeGlobals globals;
globals.setProperties(versionInfo);
ProMessageHandler msgHandler(false);
ProFileCacheManager::instance()->incRefCount();