CppTools: added ProjectPart::evaluateToolchain()

At this moment each project manager duplicates code that reads C++ code
model information from ProjectExplorer::ToolChain.
This change provides unified way.

Change-Id: If9ecfc40991aab90768dd69f5f10f31bbf5fbc21
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Sergey Shambir
2013-04-28 15:40:54 +04:00
parent 6faf45a465
commit ec8a01c150
2 changed files with 67 additions and 1 deletions

View File

@@ -29,6 +29,8 @@
#include "cppmodelmanagerinterface.h"
#include <projectexplorer/toolchain.h>
#include <projectexplorer/headerpath.h>
#include <cplusplus/pp-engine.h>
#include <QtCore/QSet>
@@ -48,6 +50,61 @@
*/
using namespace CppTools;
using namespace ProjectExplorer;
/**
* @brief Retrieves info from concrete compiler using it's flags.
* @param tc Either nullptr or toolchain for project's active target.
* @param cxxflags C++ or Objective-C++ flags.
* @param cflags C or ObjectiveC flags if possible, \a cxxflags otherwise.
*/
void ProjectPart::evaluateToolchain(const ToolChain *tc,
const QStringList &cxxflags,
const QStringList &cflags,
const Utils::FileName &sysRoot)
{
if (!tc)
return;
ToolChain::CompilerFlags cxx = tc->compilerFlags(cxxflags);
ToolChain::CompilerFlags c = (cxxflags == cflags)
? cxx : tc->compilerFlags(cflags);
if (c | ToolChain::StandardC11)
cVersion = C11;
else if (c | ToolChain::StandardC99)
cVersion = C99;
else
cVersion = C89;
if (cxx | ToolChain::StandardCxx11)
cxxVersion = CXX11;
else
cxxVersion = CXX98;
if (cxx | ToolChain::BorlandExtensions)
cxxExtensions |= BorlandExtensions;
if (cxx | ToolChain::GnuExtensions)
cxxExtensions |= GnuExtensions;
if (cxx | ToolChain::MicrosoftExtensions)
cxxExtensions |= MicrosoftExtensions;
if (cxx | ToolChain::OpenMP)
cxxExtensions |= OpenMP;
QList<HeaderPath> headers = tc->systemHeaderPaths(cxxflags, sysRoot);
foreach (const HeaderPath &header, headers)
if (header.kind() == HeaderPath::FrameworkHeaderPath)
frameworkPaths << header.path();
else
includePaths << header.path();
QByteArray macros = tc->predefinedMacros(cxxflags);
if (!macros.isEmpty()) {
if (!defines.isEmpty())
defines += '\n';
defines += macros;
defines += '\n';
}
}
static CppModelManagerInterface *g_instance = 0;