Commit 8ac43525 authored by Sergey Shambir's avatar Sergey Shambir
Browse files

AutotoolsProject: simplified C++ codemodel interaction.



Now it uses ProjectPart::evaluateToolchain() to read toolchain info with
given compiler flags.

Change-Id: I87fc03dbd450d8190e55de0635e1c8e1f8f11a40
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 535bdcc9
......@@ -408,55 +408,30 @@ void AutotoolsProject::updateCppCodeModel()
{
CppTools::CppModelManagerInterface *modelManager =
CppTools::CppModelManagerInterface::instance();
if (!modelManager)
return;
QStringList allIncludePaths = m_makefileParserThread->includePaths();
QStringList allFrameworkPaths;
QByteArray macros;
const QStringList cxxflags; // FIXME: Autotools should be able to do better than this!
QStringList cxxflags; // FIXME: Autotools should be able to do better than this!
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelManager->projectInfo(this);
pinfo.clearProjectParts();
CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart);
if (activeTarget()) {
ProjectExplorer::Kit *k = activeTarget()->kit();
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
if (tc) {
const QList<HeaderPath> allHeaderPaths = tc->systemHeaderPaths(cxxflags,
SysRootKitInformation::sysRoot(k));
foreach (const HeaderPath &headerPath, allHeaderPaths) {
if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
allFrameworkPaths.append(headerPath.path());
else
allIncludePaths.append(headerPath.path());
}
macros = tc->predefinedMacros(cxxflags);
macros += '\n';
}
part->evaluateToolchain(tc, cxxflags, cxxflags,
SysRootKitInformation::sysRoot(k));
}
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelManager->projectInfo(this);
foreach (const QString &file, m_files)
part->files << CppTools::ProjectFile(file, CppTools::ProjectFile::CXXSource);
const bool update = (pinfo.includePaths() != allIncludePaths)
|| (pinfo.sourceFiles() != m_files)
|| (pinfo.defines() != macros)
|| (pinfo.frameworkPaths() != allFrameworkPaths);
if (update) {
pinfo.clearProjectParts();
CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart);
part->includePaths = allIncludePaths;
foreach (const QString &file, m_files)
part->files << CppTools::ProjectFile(file, CppTools::ProjectFile::CXXSource);
part->defines = macros;
part->frameworkPaths = allFrameworkPaths;
part->cVersion = CppTools::ProjectPart::C99;
part->cxxVersion = CppTools::ProjectPart::CXX11;
pinfo.appendProjectPart(part);
modelManager->updateProjectInfo(pinfo);
modelManager->updateSourceFiles(m_files);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
}
part->includePaths += m_makefileParserThread->includePaths();
pinfo.appendProjectPart(part);
modelManager->updateProjectInfo(pinfo);
modelManager->updateSourceFiles(m_files);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
}
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