Commit e560ef82 authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Nikolai Kosjar

QMakeProject: put different languages into separate project parts.

This is in preparation for changes to the ProjectParts, where one part
can only hold files for 1 language.

Change-Id: I0e69e0f174341054ed89273d288a78d9aa468d59
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 43955ee5
......@@ -508,85 +508,109 @@ void QmakeProject::updateCppCodeModel()
QHash<QString, QString> uiCodeModelData;
QStringList allFiles;
foreach (QmakeProFileNode *pro, proFiles) {
ProjectPart::Ptr part(new ProjectPart);
part->project = this;
part->displayName = pro->displayName();
part->projectFile = pro->path();
ProjectPart::Ptr templatePart(new ProjectPart);
templatePart->project = this;
templatePart->displayName = pro->displayName();
templatePart->projectFile = pro->path();
if (pro->variableValue(ConfigVar).contains(QLatin1String("qt")))
part->qtVersion = qtVersionForPart;
templatePart->qtVersion = qtVersionForPart;
else
part->qtVersion = ProjectPart::NoQt;
templatePart->qtVersion = ProjectPart::NoQt;
// part->defines
part->projectDefines += pro->cxxDefines();
templatePart->projectDefines += pro->cxxDefines();
// part->headerPaths
foreach (const QString &inc, pro->variableValue(IncludePathVar))
part->headerPaths += ProjectPart::HeaderPath(inc, ProjectPart::HeaderPath::IncludePath);
templatePart->headerPaths += ProjectPart::HeaderPath(inc, ProjectPart::HeaderPath::IncludePath);
if (qtVersion) {
foreach (const HeaderPath &header, qtVersion->systemHeaderPathes(k)) {
ProjectPart::HeaderPath::Type type = ProjectPart::HeaderPath::IncludePath;
if (header.kind() == HeaderPath::FrameworkHeaderPath)
type = ProjectPart::HeaderPath::FrameworkPath;
part->headerPaths += ProjectPart::HeaderPath(header.path(), type);
templatePart->headerPaths += ProjectPart::HeaderPath(header.path(), type);
}
if (!qtVersion->frameworkInstallPath().isEmpty()) {
part->headerPaths += ProjectPart::HeaderPath(
templatePart->headerPaths += ProjectPart::HeaderPath(
qtVersion->frameworkInstallPath(),
ProjectPart::HeaderPath::FrameworkPath);
}
}
if (QmakeProFileNode *node = rootQmakeProjectNode())
part->headerPaths += ProjectPart::HeaderPath(node->resolvedMkspecPath(),
templatePart->headerPaths += ProjectPart::HeaderPath(node->resolvedMkspecPath(),
ProjectPart::HeaderPath::IncludePath);
// part->precompiledHeaders
part->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));
templatePart->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));
ProjectPart::Ptr cppPart = templatePart->copy();
{ // C++ files:
// part->files
foreach (const QString &file, pro->variableValue(CppSourceVar)) {
allFiles << file;
cppPart->files << ProjectFile(file, ProjectFile::CXXSource);
}
foreach (const QString &file, pro->variableValue(CppHeaderVar)) {
allFiles << file;
cppPart->files << ProjectFile(file, ProjectFile::CXXHeader);
}
// part->files
foreach (const QString &file, pro->variableValue(CppSourceVar)) {
allFiles << file;
part->files << ProjectFile(file, ProjectFile::CXXSource);
}
foreach (const QString &file, pro->variableValue(CppHeaderVar)) {
allFiles << file;
part->files << ProjectFile(file, ProjectFile::CXXHeader);
// Ui Files:
QHash<QString, QString> uiData = pro->uiFiles();
for (QHash<QString, QString>::const_iterator i = uiData.constBegin(); i != uiData.constEnd(); ++i) {
allFiles << i.value();
cppPart->files << ProjectFile(i.value(), ProjectFile::CXXHeader);
}
uiCodeModelData.unite(uiData);
cppPart->files.prepend(ProjectFile(CppTools::CppModelManagerInterface::configurationFileName(),
ProjectFile::CXXSource));
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
cppPart->evaluateToolchain(ToolChainKitInformation::toolChain(k),
cxxflags,
cxxflags,
SysRootKitInformation::sysRoot(k));
if (!cppPart->files.isEmpty()) {
pinfo.appendProjectPart(cppPart);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
}
}
// Ui Files:
QHash<QString, QString> uiData = pro->uiFiles();
for (QHash<QString, QString>::const_iterator i = uiData.constBegin(); i != uiData.constEnd(); ++i) {
allFiles << i.value();
part->files << ProjectFile(i.value(), ProjectFile::CXXHeader);
}
uiCodeModelData.unite(uiData);
part->files.prepend(ProjectFile(CppTools::CppModelManagerInterface::configurationFileName(),
ProjectFile::CXXSource));
foreach (const QString &file, pro->variableValue(ObjCSourceVar)) {
allFiles << file;
// Although the enum constant is called ObjCSourceVar, it actually is ObjC++ source
// code, as qmake does not handle C (and ObjC).
part->files << ProjectFile(file, ProjectFile::ObjCXXSource);
}
foreach (const QString &file, pro->variableValue(ObjCHeaderVar)) {
allFiles << file;
part->files << ProjectFile(file, ProjectFile::ObjCXXHeader);
}
ProjectPart::Ptr objcppPart = templatePart->copy();
{ // ObjC++ files:
foreach (const QString &file, pro->variableValue(ObjCSourceVar)) {
allFiles << file;
// Although the enum constant is called ObjCSourceVar, it actually is ObjC++ source
// code, as qmake does not handle C (and ObjC).
objcppPart->files << ProjectFile(file, ProjectFile::ObjCXXSource);
}
foreach (const QString &file, pro->variableValue(ObjCHeaderVar)) {
allFiles << file;
objcppPart->files << ProjectFile(file, ProjectFile::ObjCXXHeader);
}
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
part->evaluateToolchain(ToolChainKitInformation::toolChain(k),
cxxflags,
cxxflags,
SysRootKitInformation::sysRoot(k));
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
objcppPart->evaluateToolchain(ToolChainKitInformation::toolChain(k),
cxxflags,
cxxflags,
SysRootKitInformation::sysRoot(k));
pinfo.appendProjectPart(part);
}
if (!objcppPart->files.isEmpty()) {
pinfo.appendProjectPart(objcppPart);
// TODO: there is no LANG_OBJCXX, so:
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
}
}
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
if (!objcppPart->files.isEmpty())
cppPart->displayName += QLatin1String(" (C++)");
if (!cppPart->files.isEmpty())
objcppPart->displayName += QLatin1String(" (ObjC++)");
}
// Also update Ui Code Model Support:
QtSupport::UiCodeModelManager::update(this, uiCodeModelData);
......
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