Commit 04805e0a authored by dt's avatar dt
Browse files

Fixes: Use the toolchain classes int the cmake plugin.

Details:  We now get the system includes and system defines.
parent 15e2ac46
......@@ -67,7 +67,10 @@ using namespace CMakeProjectManager::Internal;
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);
}
......@@ -75,12 +78,14 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
CMakeProject::~CMakeProject()
{
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 make this function work even if it is reparsing
void CMakeProject::parseCMakeLists()
{
ProjectExplorer::ToolChain *newToolChain = 0;
QString sourceDirectory = QFileInfo(m_fileName).absolutePath();
m_manager->createXmlFile(cmakeStep()->userArguments(activeBuildConfiguration()), sourceDirectory, buildDirectory(activeBuildConfiguration()));
......@@ -88,6 +93,24 @@ void CMakeProject::parseCMakeLists()
CMakeCbpParser cbpparser;
qDebug()<<"Parsing file "<<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();
qDebug()<<"Building Tree";
// TODO do a intelligent updating of the tree
......@@ -107,18 +130,31 @@ void CMakeProject::parseCMakeLists()
}
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>();
if (modelmanager) {
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
pinfo.sourceFiles = m_files;
// TODO defines
// TODO gcc preprocessor files
pinfo.defines = m_toolChain->predefinedMacros();
pinfo.frameworkPaths = allFrameworkPaths;
modelmanager->updateProjectInfo(pinfo);
}
} else {
// TODO report error
delete m_toolChain;
m_toolChain = 0;
}
}
......@@ -188,6 +224,8 @@ QString CMakeProject::name() const
return m_projectName;
}
Core::IFile *CMakeProject::file() const
{
return m_file;
......@@ -546,6 +584,9 @@ void CMakeCbpParser::parseOption()
if (attributes().hasAttribute("title"))
m_projectName = attributes().value("title").toString();
if (attributes().hasAttribute("compiler"))
m_compiler = attributes().value("compiler").toString();
while (!atEnd()) {
readNext();
if (isEndElement()) {
......@@ -673,6 +714,11 @@ QList<CMakeTarget> CMakeCbpParser::targets()
return m_targets;
}
QString CMakeCbpParser::compilerName() const
{
return m_compiler;
}
void CMakeTarget::clear()
{
executable = QString::null;
......
......@@ -42,6 +42,7 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/toolchain.h>
#include <coreplugin/ifile.h>
#include <utils/pathchooser.h>
......@@ -122,6 +123,7 @@ private:
CMakeProjectNode* m_rootNode;
QStringList m_files;
QList<CMakeTarget> m_targets;
ProjectExplorer::ToolChain *m_toolChain;
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
......@@ -137,6 +139,7 @@ public:
QStringList includeFiles();
QList<CMakeTarget> targets();
QString projectName() const;
QString compilerName() const;
private:
void parseCodeBlocks_project_file();
void parseProject();
......@@ -159,6 +162,7 @@ private:
bool m_targetType;
QList<CMakeTarget> m_targets;
QString m_projectName;
QString m_compiler;
};
class CMakeFile : public Core::IFile
......
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