forked from qt-creator/qt-creator
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: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
43955ee53d
commit
e560ef82ef
@@ -508,86 +508,110 @@ 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));
|
||||
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
|
||||
objcppPart->evaluateToolchain(ToolChainKitInformation::toolChain(k),
|
||||
cxxflags,
|
||||
cxxflags,
|
||||
SysRootKitInformation::sysRoot(k));
|
||||
|
||||
if (!objcppPart->files.isEmpty()) {
|
||||
pinfo.appendProjectPart(objcppPart);
|
||||
// TODO: there is no LANG_OBJCXX, so:
|
||||
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
|
||||
}
|
||||
}
|
||||
|
||||
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
|
||||
part->evaluateToolchain(ToolChainKitInformation::toolChain(k),
|
||||
cxxflags,
|
||||
cxxflags,
|
||||
SysRootKitInformation::sysRoot(k));
|
||||
|
||||
pinfo.appendProjectPart(part);
|
||||
if (!objcppPart->files.isEmpty())
|
||||
cppPart->displayName += QLatin1String(" (C++)");
|
||||
if (!cppPart->files.isEmpty())
|
||||
objcppPart->displayName += QLatin1String(" (ObjC++)");
|
||||
}
|
||||
|
||||
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
|
||||
|
||||
// Also update Ui Code Model Support:
|
||||
QtSupport::UiCodeModelManager::update(this, uiCodeModelData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user