forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
|
||||
|
||||
@@ -43,8 +43,12 @@
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
namespace CPlusPlus { class LookupContext; }
|
||||
namespace ProjectExplorer { class Project; }
|
||||
namespace ProjectExplorer {
|
||||
class Project;
|
||||
class ToolChain;
|
||||
}
|
||||
namespace TextEditor { class BaseTextEditor; }
|
||||
namespace Utils { class FileName; }
|
||||
|
||||
namespace CppTools {
|
||||
class AbstractEditorSupport;
|
||||
@@ -65,6 +69,11 @@ public:
|
||||
, qtVersion(UnknownQt)
|
||||
{}
|
||||
|
||||
void evaluateToolchain(const ProjectExplorer::ToolChain *tc,
|
||||
const QStringList &cxxflags,
|
||||
const QStringList &cflags,
|
||||
const Utils::FileName &sysRoot);
|
||||
|
||||
public:
|
||||
enum CVersion {
|
||||
C89,
|
||||
|
||||
Reference in New Issue
Block a user