forked from qt-creator/qt-creator
C++: introduce a project config file field in the projectPart.
This field is used by the generic project manager which passes the ".config" file in it. The advantage is that both the SnapshotUpdater and the clang code model do not need to do anything smart, but can pass it directly to the preprocessor. Task-number: QTCREATORBUG-11390 Change-Id: I44fc7b20afd28fb59608412f2cce86af6f7e7d6b Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -65,7 +65,7 @@ namespace CppTools {
|
||||
uint qHash(const ProjectPart &p)
|
||||
{
|
||||
uint h = qHash(p.toolchainDefines) ^ qHash(p.projectDefines) ^ p.cVersion ^ p.cxxVersion
|
||||
^ p.cxxExtensions ^ p.qtVersion;
|
||||
^ p.cxxExtensions ^ p.qtVersion ^ qHash(p.projectConfigFile);
|
||||
|
||||
foreach (const QString &i, p.includePaths)
|
||||
h ^= qHash(i);
|
||||
@@ -83,6 +83,8 @@ bool operator==(const ProjectPart &p1,
|
||||
return false;
|
||||
if (p1.projectDefines != p2.projectDefines)
|
||||
return false;
|
||||
if (p1.projectConfigFile != p2.projectConfigFile)
|
||||
return false;
|
||||
if (p1.cVersion != p2.cVersion)
|
||||
return false;
|
||||
if (p1.cxxVersion != p2.cxxVersion)
|
||||
@@ -393,6 +395,8 @@ QByteArray CppModelManager::internalDefinedMacros() const
|
||||
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
|
||||
addUnique(part->toolchainDefines.split('\n'), ¯os, &alreadyIn);
|
||||
addUnique(part->projectDefines.split('\n'), ¯os, &alreadyIn);
|
||||
if (!part->projectConfigFile.isEmpty())
|
||||
macros += readProjectConfigFile(part);
|
||||
}
|
||||
}
|
||||
return macros;
|
||||
@@ -434,6 +438,7 @@ void CppModelManager::dumpModelManagerConfiguration()
|
||||
qDebug() << "cxxVersion:" << cxxVersion;
|
||||
qDebug() << "cxxExtensions:" << cxxExtensions;
|
||||
qDebug() << "Qt version:" << part->qtVersion;
|
||||
qDebug() << "project config file:" << part->projectConfigFile;
|
||||
qDebug() << "precompiled header:" << part->precompiledHeaders;
|
||||
qDebug() << "toolchain defines:" << part->toolchainDefines;
|
||||
qDebug() << "project defines:" << part->projectDefines;
|
||||
|
||||
@@ -223,4 +223,24 @@ void CppModelManagerInterface::ProjectInfo::appendProjectPart(const ProjectPart:
|
||||
m_defines.append('\n');
|
||||
m_defines.append(part->toolchainDefines);
|
||||
m_defines.append(part->projectDefines);
|
||||
if (!part->projectConfigFile.isEmpty()) {
|
||||
m_defines.append('\n');
|
||||
m_defines += readProjectConfigFile(part);
|
||||
m_defines.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray CppModelManagerInterface::readProjectConfigFile(const ProjectPart::Ptr &part)
|
||||
{
|
||||
QByteArray result;
|
||||
|
||||
QFile f(part->projectConfigFile);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream is(&f);
|
||||
result = is.readAll().toUtf8();
|
||||
f.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public:
|
||||
QString projectFile;
|
||||
ProjectExplorer::Project *project;
|
||||
QList<ProjectFile> files;
|
||||
QString projectConfigFile; // currently only used by the Generic Project Manager
|
||||
QByteArray projectDefines;
|
||||
QByteArray toolchainDefines;
|
||||
QStringList includePaths;
|
||||
@@ -290,6 +291,9 @@ public slots:
|
||||
|
||||
virtual void updateModifiedSourceFiles() = 0;
|
||||
virtual void GC() = 0;
|
||||
|
||||
protected:
|
||||
static QByteArray readProjectConfigFile(const ProjectPart::Ptr &part);
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
@@ -60,6 +60,7 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
|
||||
QStringList includePaths;
|
||||
QStringList frameworkPaths;
|
||||
QStringList precompiledHeaders;
|
||||
QString projectConfigFile;
|
||||
|
||||
updateProjectPart();
|
||||
|
||||
@@ -73,6 +74,7 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
|
||||
configFile += m_projectPart->projectDefines;
|
||||
includePaths = m_projectPart->includePaths;
|
||||
frameworkPaths = m_projectPart->frameworkPaths;
|
||||
projectConfigFile = m_projectPart->projectConfigFile;
|
||||
if (m_usePrecompiledHeaders)
|
||||
precompiledHeaders = m_projectPart->precompiledHeaders;
|
||||
}
|
||||
@@ -99,6 +101,11 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
|
||||
invalidateSnapshot = true;
|
||||
}
|
||||
|
||||
if (projectConfigFile != m_projectConfigFile) {
|
||||
m_projectConfigFile = projectConfigFile;
|
||||
invalidateSnapshot = true;
|
||||
}
|
||||
|
||||
if (precompiledHeaders != m_precompiledHeaders) {
|
||||
m_precompiledHeaders = precompiledHeaders;
|
||||
invalidateSnapshot = true;
|
||||
@@ -160,6 +167,8 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
|
||||
preproc.setIncludePaths(m_includePaths);
|
||||
preproc.setFrameworkPaths(m_frameworkPaths);
|
||||
preproc.run(configurationFileName);
|
||||
if (!m_projectConfigFile.isEmpty())
|
||||
preproc.run(m_projectConfigFile);
|
||||
if (m_usePrecompiledHeaders) {
|
||||
foreach (const QString &precompiledHeader, m_precompiledHeaders)
|
||||
preproc.run(precompiledHeader);
|
||||
|
||||
@@ -78,6 +78,7 @@ private:
|
||||
QByteArray m_editorDefines;
|
||||
QStringList m_includePaths;
|
||||
QStringList m_frameworkPaths;
|
||||
QString m_projectConfigFile;
|
||||
QStringList m_precompiledHeaders;
|
||||
CPlusPlus::Snapshot m_snapshot;
|
||||
CPlusPlus::DependencyTable m_deps;
|
||||
|
||||
Reference in New Issue
Block a user