Commit 964c01a4 authored by Erik Verbruggen's avatar Erik Verbruggen

C++: ProjectParts now contain everything that gets linked together.

Change-Id: Ib862e51897156a03a4a45e2a1690b00caeb03518
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent ace205fe
......@@ -441,7 +441,7 @@ void AutotoolsProject::updateCppCodeModel()
part->sourceFiles = m_files;
part->defines = macros;
part->frameworkPaths = allFrameworkPaths;
part->language = CPlusPlus::CppModelManagerInterface::CXX;
part->language = CPlusPlus::CppModelManagerInterface::ProjectPart::CXX;
pinfo.appendProjectPart(part);
modelManager->updateProjectInfo(pinfo);
......
......@@ -339,7 +339,7 @@ bool CMakeProject::parseCMakeLists()
part->sourceFiles = m_files;
part->defines = allDefines;
part->frameworkPaths = allFrameworkPaths;
part->language = CPlusPlus::CppModelManagerInterface::CXX;
part->language = CPlusPlus::CppModelManagerInterface::ProjectPart::CXX;
pinfo.appendProjectPart(part);
modelmanager->updateProjectInfo(pinfo);
m_codeModelFuture.cancel();
......
......@@ -1875,7 +1875,7 @@ public:
bool inProject = false;
foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
foreach (CppModelManagerInterface::ProjectPart::Ptr part, info.projectParts()) {
if (part->sourceFiles.contains(doc->fileName())) {
if (part->sourceFiles.contains(doc->fileName()) || part->objcSourceFiles.contains(doc->fileName()) || part->headerFiles.contains(doc->fileName())) {
inProject = true;
includePaths += part->includePaths;
}
......
......@@ -85,8 +85,12 @@ void CppModelManagerInterface::ProjectInfo::appendProjectPart(
// update source files
QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles);
foreach (const QString &src, part->headerFiles)
srcs.insert(src);
foreach (const QString &src, part->sourceFiles)
srcs.insert(src);
foreach (const QString &src, part->objcSourceFiles)
srcs.insert(src);
m_sourceFiles = srcs.toList();
// update defines
......
......@@ -68,37 +68,36 @@ class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
Q_OBJECT
public:
enum Language { CXX, OBJC };
class CPPTOOLS_EXPORT ProjectPart
{
public:
ProjectPart()
: language(CXX)
, cxx11Enabled(false)
, qtVersion(UnknownQt)
{}
public: //attributes
QStringList sourceFiles;
QByteArray defines;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
Language language;
bool cxx11Enabled;
public: // enums and types
enum Language { CXX, CXX11, C99, C89 };
enum QtVersion {
UnknownQt = -1,
NoQt = 0,
Qt4 = 1,
Qt5 = 2
};
QtVersion qtVersion;
bool objcEnabled() const
{ return language == CppModelManagerInterface::OBJC; }
typedef QSharedPointer<ProjectPart> Ptr;
public: //attributes
QStringList headerFiles;
QStringList sourceFiles;
QStringList objcSourceFiles;
QByteArray defines;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
Language language;
QtVersion qtVersion;
};
class CPPTOOLS_EXPORT ProjectInfo
......
......@@ -88,9 +88,10 @@
#include <sstream>
namespace CPlusPlus {
uint qHash(const CppModelManagerInterface::ProjectPart &p)
{
uint h = qHash(p.defines) ^ p.language ^ ((int) p.cxx11Enabled);
uint h = qHash(p.defines) ^ p.language ^ p.qtVersion;
foreach (const QString &i, p.includePaths)
h ^= qHash(i);
......@@ -100,6 +101,7 @@ uint qHash(const CppModelManagerInterface::ProjectPart &p)
return h;
}
bool operator==(const CppModelManagerInterface::ProjectPart &p1,
const CppModelManagerInterface::ProjectPart &p2)
{
......@@ -107,12 +109,13 @@ bool operator==(const CppModelManagerInterface::ProjectPart &p1,
return false;
if (p1.language != p2.language)
return false;
if (p1.cxx11Enabled != p2.cxx11Enabled)
if (p1.qtVersion!= p2.qtVersion)
return false;
if (p1.includePaths != p2.includePaths)
return false;
return p1.frameworkPaths == p2.frameworkPaths;
}
} // namespace CPlusPlus
using namespace CppTools;
......@@ -775,8 +778,11 @@ QStringList CppModelManager::internalProjectFiles() const
while (it.hasNext()) {
it.next();
ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
files += part->headerFiles;
files += part->sourceFiles;
files += part->objcSourceFiles;
}
}
files.removeDuplicates();
return files;
......@@ -841,14 +847,24 @@ void CppModelManager::dumpModelManagerConfiguration()
qDebug()<<" for project:"<< pinfo.project().data()->document()->fileName();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
qDebug() << "=== part ===";
qDebug() << "language:" << (part->language == CXX ? "C++" : "ObjC++");
qDebug() << "C++11:" << part->cxx11Enabled;
const char* lang;
switch (part->language) {
case ProjectPart::CXX: lang = "C++"; break;
case ProjectPart::CXX11: lang = "C++11"; break;
case ProjectPart::C89: lang = "C89"; break;
case ProjectPart::C99: lang = "C99"; break;
default: lang = "INVALID";
}
qDebug() << "language:" << lang;
qDebug() << "Qt version:" << part->qtVersion;
qDebug() << "precompiled header:" << part->precompiledHeaders;
qDebug() << "defines:" << part->defines;
qDebug() << "includes:" << part->includePaths;
qDebug() << "frameworkPaths:" << part->frameworkPaths;
qDebug() << "headers:" << part->headerFiles;
qDebug() << "sources:" << part->sourceFiles;
qDebug() << "objc sources:" << part->objcSourceFiles;
qDebug() << "";
}
}
......@@ -972,10 +988,16 @@ void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
m_srcToProjectPart.clear();
foreach (const ProjectInfo &projectInfo, m_projects.values())
foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts())
foreach (const ProjectInfo &projectInfo, m_projects.values()) {
foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) {
foreach (const QString &sourceFile, projectPart->sourceFiles)
m_srcToProjectPart[sourceFile].append(projectPart);
foreach (const QString &objcSourceFile, projectPart->objcSourceFiles)
m_srcToProjectPart[objcSourceFile].append(projectPart);
foreach (const QString &headerFile, projectPart->headerFiles)
m_srcToProjectPart[headerFile].append(projectPart);
}
}
}
if (!qgetenv("QTCREATOR_DUMP_PROJECT_INFO").isEmpty())
......
......@@ -626,27 +626,21 @@ void Qt4Project::updateCppCodeModel()
part->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));
// part->language
part->language = CPlusPlus::CppModelManagerInterface::CXX;
// part->flags
if (tc)
part->cxx11Enabled = tc->compilerFlags(pro->variableValue(CppFlagsVar)) == ToolChain::STD_CXX11;
part->language = tc->compilerFlags(pro->variableValue(CppFlagsVar)) == ToolChain::STD_CXX11 ? ProjectPart::CXX11 : ProjectPart::CXX;
else
part->language = CPlusPlus::CppModelManagerInterface::ProjectPart::CXX;
part->sourceFiles = pro->variableValue(CppSourceVar);
part->sourceFiles += pro->variableValue(CppHeaderVar);
part->sourceFiles += pro->uiFiles();
part->headerFiles += pro->variableValue(CppHeaderVar);
part->headerFiles += pro->uiFiles();
part->sourceFiles.prepend(QLatin1String("<configuration>"));
part->objcSourceFiles = pro->variableValue(ObjCSourceVar);
pinfo.appendProjectPart(part);
allFiles += part->headerFiles;
allFiles += part->sourceFiles;
part = ProjectPart::Ptr(new ProjectPart);
// todo objc code?
part->language = CPlusPlus::CppModelManagerInterface::OBJC;
part->sourceFiles = pro->variableValue(ObjCSourceVar);
if (!part->sourceFiles.isEmpty())
pinfo.appendProjectPart(part);
allFiles += part->sourceFiles;
allFiles += part->objcSourceFiles;
}
modelmanager->updateProjectInfo(pinfo);
......
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