forked from qt-creator/qt-creator
Fixes: Use the toolchain classes int the cmake plugin.
Details: We now get the system includes and system defines.
This commit is contained in:
@@ -67,7 +67,10 @@ using namespace CMakeProjectManager::Internal;
|
|||||||
|
|
||||||
|
|
||||||
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
||||||
: m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName))
|
: m_manager(manager),
|
||||||
|
m_fileName(fileName),
|
||||||
|
m_rootNode(new CMakeProjectNode(m_fileName)),
|
||||||
|
m_toolChain(0)
|
||||||
{
|
{
|
||||||
m_file = new CMakeFile(this, fileName);
|
m_file = new CMakeFile(this, fileName);
|
||||||
}
|
}
|
||||||
@@ -75,12 +78,14 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
|||||||
CMakeProject::~CMakeProject()
|
CMakeProject::~CMakeProject()
|
||||||
{
|
{
|
||||||
delete m_rootNode;
|
delete m_rootNode;
|
||||||
|
delete m_toolChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO also call this method if the CMakeLists.txt file changed, which is also called if the CMakeList.txt is updated
|
// TODO also call this method if the CMakeLists.txt file changed, which is also called if the CMakeList.txt is updated
|
||||||
// TODO make this function work even if it is reparsing
|
// TODO make this function work even if it is reparsing
|
||||||
void CMakeProject::parseCMakeLists()
|
void CMakeProject::parseCMakeLists()
|
||||||
{
|
{
|
||||||
|
ProjectExplorer::ToolChain *newToolChain = 0;
|
||||||
QString sourceDirectory = QFileInfo(m_fileName).absolutePath();
|
QString sourceDirectory = QFileInfo(m_fileName).absolutePath();
|
||||||
m_manager->createXmlFile(cmakeStep()->userArguments(activeBuildConfiguration()), sourceDirectory, buildDirectory(activeBuildConfiguration()));
|
m_manager->createXmlFile(cmakeStep()->userArguments(activeBuildConfiguration()), sourceDirectory, buildDirectory(activeBuildConfiguration()));
|
||||||
|
|
||||||
@@ -88,6 +93,24 @@ void CMakeProject::parseCMakeLists()
|
|||||||
CMakeCbpParser cbpparser;
|
CMakeCbpParser cbpparser;
|
||||||
qDebug()<<"Parsing file "<<cbpFile;
|
qDebug()<<"Parsing file "<<cbpFile;
|
||||||
if (cbpparser.parseCbpFile(cbpFile)) {
|
if (cbpparser.parseCbpFile(cbpFile)) {
|
||||||
|
qDebug()<<"CodeBlocks Compilername"<<cbpparser.compilerName();
|
||||||
|
if (cbpparser.compilerName() == "gcc") {
|
||||||
|
newToolChain = ProjectExplorer::ToolChain::createGccToolChain("gcc");
|
||||||
|
} else if (cbpparser.compilerName() == "msvc8") {
|
||||||
|
// TODO hmm
|
||||||
|
//newToolChain = ProjectExplorer::ToolChain::createMSVCToolChain("//TODO");
|
||||||
|
Q_ASSERT(false);
|
||||||
|
} else {
|
||||||
|
// TODO hmm?
|
||||||
|
}
|
||||||
|
if (newToolChain == m_toolChain) {
|
||||||
|
delete newToolChain;
|
||||||
|
newToolChain = 0;
|
||||||
|
} else {
|
||||||
|
delete m_toolChain;
|
||||||
|
m_toolChain = newToolChain;
|
||||||
|
}
|
||||||
|
|
||||||
m_projectName = cbpparser.projectName();
|
m_projectName = cbpparser.projectName();
|
||||||
qDebug()<<"Building Tree";
|
qDebug()<<"Building Tree";
|
||||||
// TODO do a intelligent updating of the tree
|
// TODO do a intelligent updating of the tree
|
||||||
@@ -107,18 +130,31 @@ void CMakeProject::parseCMakeLists()
|
|||||||
}
|
}
|
||||||
|
|
||||||
qDebug()<<"Updating CodeModel";
|
qDebug()<<"Updating CodeModel";
|
||||||
|
|
||||||
|
QStringList allIncludePaths;
|
||||||
|
QStringList allFrameworkPaths;
|
||||||
|
QList<ProjectExplorer::HeaderPath> allHeaderPaths = m_toolChain->systemHeaderPaths();
|
||||||
|
foreach (ProjectExplorer::HeaderPath headerPath, allHeaderPaths) {
|
||||||
|
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
|
||||||
|
allFrameworkPaths.append(headerPath.path());
|
||||||
|
else
|
||||||
|
allIncludePaths.append(headerPath.path());
|
||||||
|
}
|
||||||
|
allIncludePaths.append(cbpparser.includeFiles());
|
||||||
CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
|
CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
|
||||||
if (modelmanager) {
|
if (modelmanager) {
|
||||||
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
|
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
|
||||||
pinfo.includePaths = cbpparser.includeFiles();
|
pinfo.includePaths = allIncludePaths;
|
||||||
// TODO we only want C++ files, not all other stuff that might be in the project
|
// TODO we only want C++ files, not all other stuff that might be in the project
|
||||||
pinfo.sourceFiles = m_files;
|
pinfo.sourceFiles = m_files;
|
||||||
// TODO defines
|
pinfo.defines = m_toolChain->predefinedMacros();
|
||||||
// TODO gcc preprocessor files
|
pinfo.frameworkPaths = allFrameworkPaths;
|
||||||
modelmanager->updateProjectInfo(pinfo);
|
modelmanager->updateProjectInfo(pinfo);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO report error
|
// TODO report error
|
||||||
|
delete m_toolChain;
|
||||||
|
m_toolChain = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +224,8 @@ QString CMakeProject::name() const
|
|||||||
return m_projectName;
|
return m_projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Core::IFile *CMakeProject::file() const
|
Core::IFile *CMakeProject::file() const
|
||||||
{
|
{
|
||||||
return m_file;
|
return m_file;
|
||||||
@@ -546,6 +584,9 @@ void CMakeCbpParser::parseOption()
|
|||||||
if (attributes().hasAttribute("title"))
|
if (attributes().hasAttribute("title"))
|
||||||
m_projectName = attributes().value("title").toString();
|
m_projectName = attributes().value("title").toString();
|
||||||
|
|
||||||
|
if (attributes().hasAttribute("compiler"))
|
||||||
|
m_compiler = attributes().value("compiler").toString();
|
||||||
|
|
||||||
while (!atEnd()) {
|
while (!atEnd()) {
|
||||||
readNext();
|
readNext();
|
||||||
if (isEndElement()) {
|
if (isEndElement()) {
|
||||||
@@ -673,6 +714,11 @@ QList<CMakeTarget> CMakeCbpParser::targets()
|
|||||||
return m_targets;
|
return m_targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CMakeCbpParser::compilerName() const
|
||||||
|
{
|
||||||
|
return m_compiler;
|
||||||
|
}
|
||||||
|
|
||||||
void CMakeTarget::clear()
|
void CMakeTarget::clear()
|
||||||
{
|
{
|
||||||
executable = QString::null;
|
executable = QString::null;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/buildstep.h>
|
#include <projectexplorer/buildstep.h>
|
||||||
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <coreplugin/ifile.h>
|
#include <coreplugin/ifile.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
@@ -122,6 +123,7 @@ private:
|
|||||||
CMakeProjectNode* m_rootNode;
|
CMakeProjectNode* m_rootNode;
|
||||||
QStringList m_files;
|
QStringList m_files;
|
||||||
QList<CMakeTarget> m_targets;
|
QList<CMakeTarget> m_targets;
|
||||||
|
ProjectExplorer::ToolChain *m_toolChain;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
|
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
|
||||||
@@ -137,6 +139,7 @@ public:
|
|||||||
QStringList includeFiles();
|
QStringList includeFiles();
|
||||||
QList<CMakeTarget> targets();
|
QList<CMakeTarget> targets();
|
||||||
QString projectName() const;
|
QString projectName() const;
|
||||||
|
QString compilerName() const;
|
||||||
private:
|
private:
|
||||||
void parseCodeBlocks_project_file();
|
void parseCodeBlocks_project_file();
|
||||||
void parseProject();
|
void parseProject();
|
||||||
@@ -159,6 +162,7 @@ private:
|
|||||||
bool m_targetType;
|
bool m_targetType;
|
||||||
QList<CMakeTarget> m_targets;
|
QList<CMakeTarget> m_targets;
|
||||||
QString m_projectName;
|
QString m_projectName;
|
||||||
|
QString m_compiler;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMakeFile : public Core::IFile
|
class CMakeFile : public Core::IFile
|
||||||
|
|||||||
Reference in New Issue
Block a user