unify {,obj}c++{source,header} handling in qmake project manager

consistently with Xcode, qmake nowadays knows only one SOURCES list,
which is automatically classified by extension.
to replicate that, we actually copy the objective_c.prf file from qt
5.6.3 and use it to override whatever comes with qt, so we can treat all
qt versions uniformly.

also, the code model throws away the information which files were listed
as sources and which as headers. this is technically incorrect, as a
source may be only included rather than compiled, but there is no point
in extracting information which is not used.

conclusion: lump all c-like sources into one variable as far as project
processing is concerned.

and as far as configuration goes, our code model doesn't differentiate
anyway, so the duplicated setup paths can be eliminated as well.

Change-Id: I24b1bc056f8d9eb579c9378817f602912ab49971
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Oswald Buddenhagen
2016-10-25 16:28:40 +02:00
parent 4148b05e0a
commit 7e86b98836
7 changed files with 73 additions and 73 deletions

View File

@@ -458,40 +458,27 @@ void QmakeProject::updateCppCodeModel()
// part->precompiledHeaders
templatePart->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));
templatePart->updateLanguageFeatures();
// TODO: there is no LANG_OBJCXX, so:
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
CppTools::ProjectPartBuilder::evaluateProjectPartToolchain(
templatePart.data(), ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx),
cxxflags, SysRootKitInformation::sysRoot(k));
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
ProjectPart::Ptr cppPart = templatePart->copy();
{ // C++ files:
// part->files
foreach (const QString &file, pro->variableValue(CppSourceVar)) {
cppPart->files << ProjectFile(file, ProjectFile::CXXSource);
}
foreach (const QString &file, pro->variableValue(CppHeaderVar)) {
cppPart->files << ProjectFile(file, ProjectFile::CXXHeader);
}
}
ProjectPart::Ptr objcppPart = templatePart->copy();
{ // ObjC++ files:
foreach (const QString &file, pro->variableValue(ObjCSourceVar)) {
// 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)) {
objcppPart->files << ProjectFile(file, ProjectFile::ObjCXXHeader);
}
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
CppTools::ProjectPartBuilder::evaluateProjectPartToolchain(objcppPart.data(),
ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx),
cxxflags,
SysRootKitInformation::sysRoot(k));
if (!objcppPart->files.isEmpty()) {
pinfo.appendProjectPart(objcppPart);
// TODO: there is no LANG_OBJCXX, so:
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
foreach (const QString &file, pro->variableValue(SourceVar)) {
ProjectFile::Kind kind = ProjectFile::classify(file);
switch (kind) {
case ProjectFile::ObjCHeader:
case ProjectFile::ObjCSource:
case ProjectFile::ObjCXXHeader:
case ProjectFile::ObjCXXSource:
objcppPart->files << ProjectFile(file, kind);
break;
default:
cppPart->files << ProjectFile(file, kind);
break;
}
}
@@ -523,19 +510,12 @@ void QmakeProject::updateCppCodeModel()
cppPart->files.prepend(ProjectFile(CppTools::CppModelManager::configurationFileName(),
ProjectFile::CXXSource));
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
CppTools::ProjectPartBuilder::evaluateProjectPartToolchain(
cppPart.data(), ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx),
cxxflags, SysRootKitInformation::sysRoot(k));
if (!cppPart->files.isEmpty()) {
pinfo.appendProjectPart(cppPart);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
}
if (!objcppPart->files.isEmpty())
pinfo.appendProjectPart(cppPart);
objcppPart->displayName += QLatin1String(" (ObjC++)");
if (!objcppPart->files.isEmpty()) {
pinfo.appendProjectPart(objcppPart);
cppPart->displayName += QLatin1String(" (C++)");
if (!cppPart->files.isEmpty())
objcppPart->displayName += QLatin1String(" (ObjC++)");
}
}
pinfo.finish();