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,85 +508,109 @@ void QmakeProject::updateCppCodeModel()
|
|||||||
QHash<QString, QString> uiCodeModelData;
|
QHash<QString, QString> uiCodeModelData;
|
||||||
QStringList allFiles;
|
QStringList allFiles;
|
||||||
foreach (QmakeProFileNode *pro, proFiles) {
|
foreach (QmakeProFileNode *pro, proFiles) {
|
||||||
ProjectPart::Ptr part(new ProjectPart);
|
ProjectPart::Ptr templatePart(new ProjectPart);
|
||||||
part->project = this;
|
templatePart->project = this;
|
||||||
part->displayName = pro->displayName();
|
templatePart->displayName = pro->displayName();
|
||||||
part->projectFile = pro->path();
|
templatePart->projectFile = pro->path();
|
||||||
|
|
||||||
if (pro->variableValue(ConfigVar).contains(QLatin1String("qt")))
|
if (pro->variableValue(ConfigVar).contains(QLatin1String("qt")))
|
||||||
part->qtVersion = qtVersionForPart;
|
templatePart->qtVersion = qtVersionForPart;
|
||||||
else
|
else
|
||||||
part->qtVersion = ProjectPart::NoQt;
|
templatePart->qtVersion = ProjectPart::NoQt;
|
||||||
|
|
||||||
// part->defines
|
// part->defines
|
||||||
part->projectDefines += pro->cxxDefines();
|
templatePart->projectDefines += pro->cxxDefines();
|
||||||
|
|
||||||
// part->headerPaths
|
// part->headerPaths
|
||||||
foreach (const QString &inc, pro->variableValue(IncludePathVar))
|
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) {
|
if (qtVersion) {
|
||||||
foreach (const HeaderPath &header, qtVersion->systemHeaderPathes(k)) {
|
foreach (const HeaderPath &header, qtVersion->systemHeaderPathes(k)) {
|
||||||
ProjectPart::HeaderPath::Type type = ProjectPart::HeaderPath::IncludePath;
|
ProjectPart::HeaderPath::Type type = ProjectPart::HeaderPath::IncludePath;
|
||||||
if (header.kind() == HeaderPath::FrameworkHeaderPath)
|
if (header.kind() == HeaderPath::FrameworkHeaderPath)
|
||||||
type = ProjectPart::HeaderPath::FrameworkPath;
|
type = ProjectPart::HeaderPath::FrameworkPath;
|
||||||
part->headerPaths += ProjectPart::HeaderPath(header.path(), type);
|
templatePart->headerPaths += ProjectPart::HeaderPath(header.path(), type);
|
||||||
}
|
}
|
||||||
if (!qtVersion->frameworkInstallPath().isEmpty()) {
|
if (!qtVersion->frameworkInstallPath().isEmpty()) {
|
||||||
part->headerPaths += ProjectPart::HeaderPath(
|
templatePart->headerPaths += ProjectPart::HeaderPath(
|
||||||
qtVersion->frameworkInstallPath(),
|
qtVersion->frameworkInstallPath(),
|
||||||
ProjectPart::HeaderPath::FrameworkPath);
|
ProjectPart::HeaderPath::FrameworkPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QmakeProFileNode *node = rootQmakeProjectNode())
|
if (QmakeProFileNode *node = rootQmakeProjectNode())
|
||||||
part->headerPaths += ProjectPart::HeaderPath(node->resolvedMkspecPath(),
|
templatePart->headerPaths += ProjectPart::HeaderPath(node->resolvedMkspecPath(),
|
||||||
ProjectPart::HeaderPath::IncludePath);
|
ProjectPart::HeaderPath::IncludePath);
|
||||||
|
|
||||||
// part->precompiledHeaders
|
// part->precompiledHeaders
|
||||||
part->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));
|
templatePart->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));
|
||||||
|
|
||||||
|
ProjectPart::Ptr cppPart = templatePart->copy();
|
||||||
|
{ // C++ files:
|
||||||
// part->files
|
// part->files
|
||||||
foreach (const QString &file, pro->variableValue(CppSourceVar)) {
|
foreach (const QString &file, pro->variableValue(CppSourceVar)) {
|
||||||
allFiles << file;
|
allFiles << file;
|
||||||
part->files << ProjectFile(file, ProjectFile::CXXSource);
|
cppPart->files << ProjectFile(file, ProjectFile::CXXSource);
|
||||||
}
|
}
|
||||||
foreach (const QString &file, pro->variableValue(CppHeaderVar)) {
|
foreach (const QString &file, pro->variableValue(CppHeaderVar)) {
|
||||||
allFiles << file;
|
allFiles << file;
|
||||||
part->files << ProjectFile(file, ProjectFile::CXXHeader);
|
cppPart->files << ProjectFile(file, ProjectFile::CXXHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ui Files:
|
// Ui Files:
|
||||||
QHash<QString, QString> uiData = pro->uiFiles();
|
QHash<QString, QString> uiData = pro->uiFiles();
|
||||||
for (QHash<QString, QString>::const_iterator i = uiData.constBegin(); i != uiData.constEnd(); ++i) {
|
for (QHash<QString, QString>::const_iterator i = uiData.constBegin(); i != uiData.constEnd(); ++i) {
|
||||||
allFiles << i.value();
|
allFiles << i.value();
|
||||||
part->files << ProjectFile(i.value(), ProjectFile::CXXHeader);
|
cppPart->files << ProjectFile(i.value(), ProjectFile::CXXHeader);
|
||||||
}
|
}
|
||||||
uiCodeModelData.unite(uiData);
|
uiCodeModelData.unite(uiData);
|
||||||
|
|
||||||
part->files.prepend(ProjectFile(CppTools::CppModelManagerInterface::configurationFileName(),
|
cppPart->files.prepend(ProjectFile(CppTools::CppModelManagerInterface::configurationFileName(),
|
||||||
ProjectFile::CXXSource));
|
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);
|
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
|
||||||
part->evaluateToolchain(ToolChainKitInformation::toolChain(k),
|
cppPart->evaluateToolchain(ToolChainKitInformation::toolChain(k),
|
||||||
cxxflags,
|
cxxflags,
|
||||||
cxxflags,
|
cxxflags,
|
||||||
SysRootKitInformation::sysRoot(k));
|
SysRootKitInformation::sysRoot(k));
|
||||||
|
|
||||||
pinfo.appendProjectPart(part);
|
if (!cppPart->files.isEmpty()) {
|
||||||
|
pinfo.appendProjectPart(cppPart);
|
||||||
|
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
|
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);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!objcppPart->files.isEmpty())
|
||||||
|
cppPart->displayName += QLatin1String(" (C++)");
|
||||||
|
if (!cppPart->files.isEmpty())
|
||||||
|
objcppPart->displayName += QLatin1String(" (ObjC++)");
|
||||||
|
}
|
||||||
|
|
||||||
// Also update Ui Code Model Support:
|
// Also update Ui Code Model Support:
|
||||||
QtSupport::UiCodeModelManager::update(this, uiCodeModelData);
|
QtSupport::UiCodeModelManager::update(this, uiCodeModelData);
|
||||||
|
|||||||
Reference in New Issue
Block a user