2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "cmakeproject.h"
|
|
|
|
#include "cmakeprojectconstants.h"
|
|
|
|
#include "cmakeprojectnodes.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
#include "cmakerunconfiguration.h"
|
2008-12-05 16:30:26 +01:00
|
|
|
#include "makestep.h"
|
2009-03-09 18:13:19 +01:00
|
|
|
#include "cmakeopenprojectwizard.h"
|
2009-05-26 15:22:11 +02:00
|
|
|
#include "cmakebuildenvironmentwidget.h"
|
2009-11-23 12:11:48 +01:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2009-02-16 13:12:12 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <cpptools/cppmodelmanagerinterface.h>
|
2009-01-23 16:57:38 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2009-01-23 16:57:38 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2009-03-16 17:33:05 +01:00
|
|
|
#include <QtCore/QMap>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDebug>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <QtCore/QDir>
|
2009-03-16 17:33:05 +01:00
|
|
|
#include <QtCore/QDateTime>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <QtCore/QProcess>
|
2009-01-12 15:10:33 +01:00
|
|
|
#include <QtGui/QFormLayout>
|
2009-01-23 16:57:38 +01:00
|
|
|
#include <QtGui/QMainWindow>
|
2009-09-24 16:02:02 +02:00
|
|
|
#include <QtGui/QInputDialog>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
using namespace CMakeProjectManager::Internal;
|
2009-09-24 16:02:02 +02:00
|
|
|
using namespace ProjectExplorer;
|
2009-05-26 15:22:11 +02:00
|
|
|
using ProjectExplorer::Environment;
|
|
|
|
using ProjectExplorer::EnvironmentItem;
|
2008-12-12 17:22:02 +01:00
|
|
|
|
|
|
|
// QtCreator CMake Generator wishlist:
|
|
|
|
// Which make targets we need to build to get all executables
|
|
|
|
// What is the make we need to call
|
|
|
|
// What is the actual compiler executable
|
|
|
|
// DEFINES
|
|
|
|
|
|
|
|
// Open Questions
|
|
|
|
// Who sets up the environment for cl.exe ? INCLUDEPATH and so on
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
/*!
|
|
|
|
\class CMakeBuildConfigurationFactory
|
|
|
|
*/
|
2008-12-12 17:22:02 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory(CMakeProject *project)
|
|
|
|
: IBuildConfigurationFactory(project),
|
|
|
|
m_project(project)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CMakeBuildConfigurationFactory::~CMakeBuildConfigurationFactory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList CMakeBuildConfigurationFactory::availableCreationTypes() const
|
|
|
|
{
|
|
|
|
return QStringList() << "Create";
|
|
|
|
}
|
|
|
|
|
2009-10-01 14:56:29 +02:00
|
|
|
QString CMakeBuildConfigurationFactory::displayNameForType(const QString & /* type */) const
|
2009-09-24 16:02:02 +02:00
|
|
|
{
|
|
|
|
return tr("Create");
|
|
|
|
}
|
|
|
|
|
2009-11-23 13:29:45 +01:00
|
|
|
BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &type) const
|
2009-09-24 16:02:02 +02:00
|
|
|
{
|
2009-09-30 11:27:31 +02:00
|
|
|
QTC_ASSERT(type == "Create", return false);
|
2009-09-24 16:02:02 +02:00
|
|
|
|
|
|
|
//TODO configuration name should be part of the cmakeopenprojectwizard
|
|
|
|
bool ok;
|
|
|
|
QString buildConfigurationName = QInputDialog::getText(0,
|
|
|
|
tr("New configuration"),
|
|
|
|
tr("New Configuration Name:"),
|
|
|
|
QLineEdit::Normal,
|
|
|
|
QString(),
|
|
|
|
&ok);
|
|
|
|
if (!ok || buildConfigurationName.isEmpty())
|
2009-09-30 11:27:31 +02:00
|
|
|
return false;
|
2009-11-24 15:36:31 +01:00
|
|
|
BuildConfiguration *bc = new CMakeBuildConfiguration(m_project);
|
|
|
|
bc->setDisplayName(buildConfigurationName);
|
2009-09-24 16:02:02 +02:00
|
|
|
|
2009-11-23 15:47:26 +01:00
|
|
|
MakeStep *makeStep = new MakeStep(bc);
|
2009-10-27 14:16:28 +01:00
|
|
|
bc->insertBuildStep(0, makeStep);
|
|
|
|
|
2009-11-23 15:47:26 +01:00
|
|
|
MakeStep *cleanMakeStep = new MakeStep(bc);
|
2009-10-27 14:16:28 +01:00
|
|
|
bc->insertCleanStep(0, cleanMakeStep);
|
|
|
|
cleanMakeStep->setClean(true);
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
CMakeOpenProjectWizard copw(m_project->projectManager(),
|
|
|
|
m_project->sourceDirectory(),
|
2009-11-25 18:50:20 +01:00
|
|
|
bc->buildDirectory(),
|
|
|
|
bc->environment());
|
2009-09-24 16:02:02 +02:00
|
|
|
if (copw.exec() != QDialog::Accepted) {
|
|
|
|
delete bc;
|
2009-09-30 11:27:31 +02:00
|
|
|
return false;
|
2009-09-24 16:02:02 +02:00
|
|
|
}
|
2009-09-30 12:19:22 +02:00
|
|
|
m_project->addBuildConfiguration(bc); // this also makes the name unique
|
2009-10-27 14:16:28 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
bc->setValue("buildDirectory", copw.buildDirectory());
|
|
|
|
bc->setValue("msvcVersion", copw.msvcVersion());
|
|
|
|
m_project->parseCMakeLists();
|
2009-10-27 14:16:28 +01:00
|
|
|
|
|
|
|
// Default to all
|
|
|
|
if (m_project->targets().contains("all"))
|
|
|
|
makeStep->setBuildTarget("all", true);
|
2009-11-23 13:29:45 +01:00
|
|
|
return bc;
|
2009-09-24 16:02:02 +02:00
|
|
|
}
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::BuildConfiguration *source) const
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
|
|
|
CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
|
2009-11-24 15:36:31 +01:00
|
|
|
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(old);
|
2009-11-23 13:29:45 +01:00
|
|
|
return bc;
|
|
|
|
}
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
BuildConfiguration *CMakeBuildConfigurationFactory::restore() const
|
2009-11-23 13:29:45 +01:00
|
|
|
{
|
2009-11-24 15:36:31 +01:00
|
|
|
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project);
|
2009-11-23 13:29:45 +01:00
|
|
|
return bc;
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
/*!
|
|
|
|
\class CMakeProject
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
2009-02-11 12:14:51 +01:00
|
|
|
: m_manager(manager),
|
|
|
|
m_fileName(fileName),
|
2009-09-24 16:02:02 +02:00
|
|
|
m_buildConfigurationFactory(new CMakeBuildConfigurationFactory(this)),
|
2009-02-11 12:14:51 +01:00
|
|
|
m_rootNode(new CMakeProjectNode(m_fileName)),
|
2009-03-26 17:36:58 +01:00
|
|
|
m_insideFileChanged(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
m_file = new CMakeFile(this, fileName);
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CMakeProject::~CMakeProject()
|
|
|
|
{
|
|
|
|
delete m_rootNode;
|
|
|
|
}
|
|
|
|
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *CMakeProject::activeCMakeBuildConfiguration() const
|
|
|
|
{
|
|
|
|
return static_cast<CMakeBuildConfiguration *>(activeBuildConfiguration());
|
|
|
|
}
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
IBuildConfigurationFactory *CMakeProject::buildConfigurationFactory() const
|
|
|
|
{
|
|
|
|
return m_buildConfigurationFactory;
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:07:52 +02:00
|
|
|
void CMakeProject::slotActiveBuildConfiguration()
|
|
|
|
{
|
2009-09-24 16:02:02 +02:00
|
|
|
BuildConfiguration *activeBC = activeBuildConfiguration();
|
2009-05-18 18:07:52 +02:00
|
|
|
// Pop up a dialog asking the user to rerun cmake
|
|
|
|
QFileInfo sourceFileInfo(m_fileName);
|
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory()));
|
2009-05-18 18:07:52 +02:00
|
|
|
QFileInfo cbpFileFi(cbpFile);
|
2009-09-14 16:09:17 +02:00
|
|
|
CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing;
|
|
|
|
if (!cbpFileFi.exists()) {
|
2009-05-26 15:50:27 +02:00
|
|
|
mode = CMakeOpenProjectWizard::NeedToCreate;
|
2009-09-14 16:09:17 +02:00
|
|
|
} else {
|
|
|
|
foreach(const QString &file, m_watchedFiles) {
|
2009-09-23 15:28:12 +02:00
|
|
|
if (QFileInfo(file).lastModified() > cbpFileFi.lastModified()) {
|
2009-09-14 16:09:17 +02:00
|
|
|
mode = CMakeOpenProjectWizard::NeedToUpdate;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-18 18:07:52 +02:00
|
|
|
|
2009-05-26 15:50:27 +02:00
|
|
|
if (mode != CMakeOpenProjectWizard::Nothing) {
|
2009-05-26 16:10:13 +02:00
|
|
|
CMakeOpenProjectWizard copw(m_manager,
|
|
|
|
sourceFileInfo.absolutePath(),
|
2009-11-25 18:50:20 +01:00
|
|
|
activeBC->buildDirectory(),
|
2009-05-26 16:10:13 +02:00
|
|
|
mode,
|
2009-11-25 18:50:20 +01:00
|
|
|
activeBC->environment());
|
2009-05-18 18:07:52 +02:00
|
|
|
copw.exec();
|
2009-09-24 16:02:02 +02:00
|
|
|
activeBC->setValue("msvcVersion", copw.msvcVersion());
|
2009-05-18 18:07:52 +02:00
|
|
|
}
|
|
|
|
// reparse
|
|
|
|
parseCMakeLists();
|
|
|
|
}
|
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
void CMakeProject::fileChanged(const QString &fileName)
|
|
|
|
{
|
2009-09-23 15:00:02 +02:00
|
|
|
Q_UNUSED(fileName)
|
2009-03-26 17:36:58 +01:00
|
|
|
if (m_insideFileChanged== true)
|
|
|
|
return;
|
|
|
|
m_insideFileChanged = true;
|
2009-09-14 16:09:17 +02:00
|
|
|
slotActiveBuildConfiguration();
|
2009-03-26 17:36:58 +01:00
|
|
|
m_insideFileChanged = false;
|
|
|
|
}
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
void CMakeProject::changeBuildDirectory(BuildConfiguration *configuration, const QString &newBuildDirectory)
|
2009-04-20 14:35:25 +02:00
|
|
|
{
|
2009-09-24 16:02:02 +02:00
|
|
|
configuration->setValue("buildDirectory", newBuildDirectory);
|
2009-04-20 14:35:25 +02:00
|
|
|
parseCMakeLists();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CMakeProject::sourceDirectory() const
|
|
|
|
{
|
|
|
|
return QFileInfo(m_fileName).absolutePath();
|
|
|
|
}
|
|
|
|
|
2009-07-03 16:46:01 +02:00
|
|
|
bool CMakeProject::parseCMakeLists()
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-03-26 17:36:58 +01:00
|
|
|
// Find cbp file
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *activeBC = activeCMakeBuildConfiguration();
|
|
|
|
QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory());
|
2009-03-26 17:36:58 +01:00
|
|
|
|
|
|
|
// setFolderName
|
2009-03-20 16:13:46 +01:00
|
|
|
m_rootNode->setFolderName(QFileInfo(cbpFile).completeBaseName());
|
2008-12-02 17:56:21 +01:00
|
|
|
CMakeCbpParser cbpparser;
|
2009-03-26 17:36:58 +01:00
|
|
|
// Parsing
|
|
|
|
//qDebug()<<"Parsing file "<<cbpFile;
|
2009-09-24 16:02:02 +02:00
|
|
|
if (cbpparser.parseCbpFile(cbpFile)) {
|
2009-03-26 17:36:58 +01:00
|
|
|
// ToolChain
|
2009-11-26 14:43:27 +01:00
|
|
|
activeBC->updateToolChain(cbpparser.compilerName());
|
2009-02-11 12:14:51 +01:00
|
|
|
|
2009-01-15 14:48:28 +00:00
|
|
|
m_projectName = cbpparser.projectName();
|
2009-03-16 17:33:05 +01:00
|
|
|
m_rootNode->setFolderName(cbpparser.projectName());
|
2009-03-03 17:56:03 +01:00
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
//qDebug()<<"Building Tree";
|
|
|
|
|
2009-06-30 17:38:27 +02:00
|
|
|
|
2009-03-03 17:56:03 +01:00
|
|
|
QList<ProjectExplorer::FileNode *> fileList = cbpparser.fileList();
|
2009-06-30 17:38:27 +02:00
|
|
|
|
2009-09-14 16:09:17 +02:00
|
|
|
QSet<QString> projectFiles;
|
2009-06-30 17:38:27 +02:00
|
|
|
if (cbpparser.hasCMakeFiles()) {
|
|
|
|
fileList.append(cbpparser.cmakeFileList());
|
2009-09-14 16:09:17 +02:00
|
|
|
foreach(ProjectExplorer::FileNode *node, cbpparser.cmakeFileList())
|
|
|
|
projectFiles.insert(node->path());
|
2009-06-30 17:38:27 +02:00
|
|
|
} else {
|
|
|
|
// Manually add the CMakeLists.txt file
|
2009-09-14 16:09:17 +02:00
|
|
|
QString cmakeListTxt = sourceDirectory() + "/CMakeLists.txt";
|
|
|
|
fileList.append(new ProjectExplorer::FileNode(cmakeListTxt, ProjectExplorer::ProjectFileType, false));
|
|
|
|
projectFiles.insert(cmakeListTxt);
|
2009-06-30 17:38:27 +02:00
|
|
|
}
|
2009-03-13 13:55:59 +01:00
|
|
|
|
2009-09-14 16:09:17 +02:00
|
|
|
|
|
|
|
QSet<QString> added = projectFiles;
|
|
|
|
added.subtract(m_watchedFiles);
|
|
|
|
foreach(const QString &add, added)
|
|
|
|
m_watcher->addFile(add);
|
|
|
|
foreach(const QString &remove, m_watchedFiles.subtract(projectFiles))
|
|
|
|
m_watcher->removeFile(remove);
|
|
|
|
m_watchedFiles = projectFiles;
|
|
|
|
|
2009-03-16 17:33:05 +01:00
|
|
|
m_files.clear();
|
2009-03-03 17:56:03 +01:00
|
|
|
foreach (ProjectExplorer::FileNode *fn, fileList)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_files.append(fn->path());
|
|
|
|
m_files.sort();
|
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
buildTree(m_rootNode, fileList);
|
|
|
|
|
|
|
|
|
|
|
|
//qDebug()<<"Adding Targets";
|
2008-12-09 14:13:29 +01:00
|
|
|
m_targets = cbpparser.targets();
|
2009-03-16 17:33:05 +01:00
|
|
|
// qDebug()<<"Printing targets";
|
|
|
|
// foreach(CMakeTarget ct, m_targets) {
|
|
|
|
// qDebug()<<ct.title<<" with executable:"<<ct.executable;
|
|
|
|
// qDebug()<<"WD:"<<ct.workingDirectory;
|
|
|
|
// qDebug()<<ct.makeCommand<<ct.makeCleanCommand;
|
|
|
|
// qDebug()<<"";
|
|
|
|
// }
|
2008-12-09 14:13:29 +01:00
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
//qDebug()<<"Updating CodeModel";
|
2009-02-11 12:14:51 +01:00
|
|
|
|
|
|
|
QStringList allIncludePaths;
|
|
|
|
QStringList allFrameworkPaths;
|
2009-11-26 14:43:27 +01:00
|
|
|
QList<ProjectExplorer::HeaderPath> allHeaderPaths = activeBC->toolChain()->systemHeaderPaths();
|
2009-02-11 12:14:51 +01:00
|
|
|
foreach (ProjectExplorer::HeaderPath headerPath, allHeaderPaths) {
|
|
|
|
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
|
|
|
|
allFrameworkPaths.append(headerPath.path());
|
|
|
|
else
|
|
|
|
allIncludePaths.append(headerPath.path());
|
|
|
|
}
|
2009-03-27 12:15:20 +01:00
|
|
|
// This explicitly adds -I. to the include paths
|
2009-04-20 14:35:25 +02:00
|
|
|
allIncludePaths.append(sourceDirectory());
|
2009-03-27 12:15:20 +01:00
|
|
|
|
2009-02-11 12:14:51 +01:00
|
|
|
allIncludePaths.append(cbpparser.includeFiles());
|
2008-12-02 12:01:29 +01:00
|
|
|
CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
|
|
|
|
if (modelmanager) {
|
2008-12-08 10:44:56 +01:00
|
|
|
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
|
2009-07-03 18:56:48 +02:00
|
|
|
if (pinfo.includePaths != allIncludePaths
|
|
|
|
|| pinfo.sourceFiles != m_files
|
2009-11-26 14:43:27 +01:00
|
|
|
|| pinfo.defines != activeBC->toolChain()->predefinedMacros()
|
2009-07-03 18:56:48 +02:00
|
|
|
|| pinfo.frameworkPaths != allFrameworkPaths) {
|
|
|
|
pinfo.includePaths = allIncludePaths;
|
|
|
|
// TODO we only want C++ files, not all other stuff that might be in the project
|
|
|
|
pinfo.sourceFiles = m_files;
|
2009-11-26 14:43:27 +01:00
|
|
|
pinfo.defines = activeBC->toolChain()->predefinedMacros(); // TODO this is to simplistic
|
2009-07-03 18:56:48 +02:00
|
|
|
pinfo.frameworkPaths = allFrameworkPaths;
|
|
|
|
modelmanager->updateProjectInfo(pinfo);
|
|
|
|
modelmanager->updateSourceFiles(pinfo.sourceFiles);
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-03-16 17:33:05 +01:00
|
|
|
|
|
|
|
// Create run configurations for m_targets
|
2009-03-26 17:36:58 +01:00
|
|
|
//qDebug()<<"Create run configurations of m_targets";
|
2009-10-08 18:37:18 +02:00
|
|
|
QMultiMap<QString, CMakeRunConfiguration* > existingRunConfigurations;
|
|
|
|
foreach(ProjectExplorer::RunConfiguration* cmakeRunConfiguration, runConfigurations()) {
|
|
|
|
if (CMakeRunConfiguration* rc = qobject_cast<CMakeRunConfiguration *>(cmakeRunConfiguration)) {
|
2009-03-16 17:33:05 +01:00
|
|
|
existingRunConfigurations.insert(rc->title(), rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-06 17:01:26 +02:00
|
|
|
bool setActive = existingRunConfigurations.isEmpty();
|
2009-03-16 17:33:05 +01:00
|
|
|
foreach(const CMakeTarget &ct, m_targets) {
|
|
|
|
if (ct.executable.isEmpty())
|
|
|
|
continue;
|
|
|
|
if (ct.title.endsWith("/fast"))
|
|
|
|
continue;
|
2009-10-08 18:37:18 +02:00
|
|
|
QList<CMakeRunConfiguration *> list = existingRunConfigurations.values(ct.title);
|
2009-04-06 17:01:26 +02:00
|
|
|
if (!list.isEmpty()) {
|
2009-03-16 17:33:05 +01:00
|
|
|
// Already exists, so override the settings...
|
2009-10-08 18:37:18 +02:00
|
|
|
foreach (CMakeRunConfiguration *rc, list) {
|
2009-04-06 17:01:26 +02:00
|
|
|
//qDebug()<<"Updating Run Configuration with title"<<ct.title;
|
|
|
|
//qDebug()<<" Executable new:"<<ct.executable<< "old:"<<rc->executable();
|
|
|
|
//qDebug()<<" WD new:"<<ct.workingDirectory<<"old:"<<rc->workingDirectory();
|
|
|
|
rc->setExecutable(ct.executable);
|
|
|
|
rc->setWorkingDirectory(ct.workingDirectory);
|
|
|
|
}
|
|
|
|
existingRunConfigurations.remove(ct.title);
|
2009-03-16 17:33:05 +01:00
|
|
|
} else {
|
|
|
|
// Does not exist yet
|
2009-03-26 17:36:58 +01:00
|
|
|
//qDebug()<<"Adding new run configuration with title"<<ct.title;
|
|
|
|
//qDebug()<<" Executable:"<<ct.executable<<"WD:"<<ct.workingDirectory;
|
2009-10-08 18:37:18 +02:00
|
|
|
ProjectExplorer::RunConfiguration *rc(new CMakeRunConfiguration(this, ct.executable, ct.workingDirectory, ct.title));
|
2009-03-16 17:33:05 +01:00
|
|
|
addRunConfiguration(rc);
|
|
|
|
// The first one gets the honour of beeing the active one
|
2009-04-06 17:01:26 +02:00
|
|
|
if (setActive) {
|
2009-03-16 17:33:05 +01:00
|
|
|
setActiveRunConfiguration(rc);
|
2009-04-06 17:01:26 +02:00
|
|
|
setActive = false;
|
2009-03-16 17:33:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-08 18:37:18 +02:00
|
|
|
QMultiMap<QString, CMakeRunConfiguration *>::const_iterator it =
|
2009-03-16 17:33:05 +01:00
|
|
|
existingRunConfigurations.constBegin();
|
|
|
|
for( ; it != existingRunConfigurations.constEnd(); ++it) {
|
2009-10-08 18:37:18 +02:00
|
|
|
CMakeRunConfiguration *rc = it.value();
|
2009-03-26 17:36:58 +01:00
|
|
|
//qDebug()<<"Removing old RunConfiguration with title:"<<rc->title();
|
|
|
|
//qDebug()<<" Executable:"<<rc->executable()<<rc->workingDirectory();
|
2009-03-16 17:33:05 +01:00
|
|
|
removeRunConfiguration(rc);
|
|
|
|
}
|
2009-03-26 17:36:58 +01:00
|
|
|
//qDebug()<<"\n";
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
|
|
|
// TODO report error
|
2009-03-16 17:33:05 +01:00
|
|
|
qDebug()<<"Parsing failed";
|
2009-11-26 14:43:27 +01:00
|
|
|
activeBC->updateToolChain(QString::null);
|
2009-07-03 16:46:01 +02:00
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-07-03 16:46:01 +02:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 15:10:33 +01:00
|
|
|
QStringList CMakeProject::targets() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-12 15:10:33 +01:00
|
|
|
QStringList results;
|
2009-04-06 17:01:26 +02:00
|
|
|
foreach (const CMakeTarget &ct, m_targets) {
|
|
|
|
if (ct.executable.isEmpty())
|
|
|
|
continue;
|
|
|
|
if (ct.title.endsWith("/fast"))
|
|
|
|
continue;
|
2009-01-12 15:10:33 +01:00
|
|
|
results << ct.title;
|
2009-04-06 17:01:26 +02:00
|
|
|
}
|
2009-01-12 15:10:33 +01:00
|
|
|
return results;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
void CMakeProject::gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-03-26 17:36:58 +01:00
|
|
|
foreach(ProjectExplorer::FolderNode *folder, parent->subFolderNodes())
|
|
|
|
gatherFileNodes(folder, list);
|
|
|
|
foreach(ProjectExplorer::FileNode *file, parent->fileNodes())
|
|
|
|
list.append(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> newList)
|
|
|
|
{
|
|
|
|
// Gather old list
|
|
|
|
QList<ProjectExplorer::FileNode *> oldList;
|
|
|
|
gatherFileNodes(rootNode, oldList);
|
|
|
|
qSort(oldList.begin(), oldList.end(), ProjectExplorer::ProjectNode::sortNodesByPath);
|
|
|
|
qSort(newList.begin(), newList.end(), ProjectExplorer::ProjectNode::sortNodesByPath);
|
|
|
|
|
|
|
|
// generate added and deleted list
|
|
|
|
QList<ProjectExplorer::FileNode *>::const_iterator oldIt = oldList.constBegin();
|
|
|
|
QList<ProjectExplorer::FileNode *>::const_iterator oldEnd = oldList.constEnd();
|
|
|
|
QList<ProjectExplorer::FileNode *>::const_iterator newIt = newList.constBegin();
|
|
|
|
QList<ProjectExplorer::FileNode *>::const_iterator newEnd = newList.constEnd();
|
|
|
|
|
|
|
|
QList<ProjectExplorer::FileNode *> added;
|
|
|
|
QList<ProjectExplorer::FileNode *> deleted;
|
|
|
|
|
|
|
|
|
|
|
|
while(oldIt != oldEnd && newIt != newEnd) {
|
|
|
|
if ( (*oldIt)->path() == (*newIt)->path()) {
|
|
|
|
delete *newIt;
|
|
|
|
++oldIt;
|
|
|
|
++newIt;
|
|
|
|
} else if ((*oldIt)->path() < (*newIt)->path()) {
|
|
|
|
deleted.append(*oldIt);
|
|
|
|
++oldIt;
|
|
|
|
} else {
|
|
|
|
added.append(*newIt);
|
|
|
|
++newIt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (oldIt != oldEnd) {
|
|
|
|
deleted.append(*oldIt);
|
|
|
|
++oldIt;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (newIt != newEnd) {
|
|
|
|
added.append(*newIt);
|
|
|
|
++newIt;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add added nodes
|
|
|
|
foreach (ProjectExplorer::FileNode *fn, added) {
|
|
|
|
// qDebug()<<"added"<<fn->path();
|
2008-12-02 12:01:29 +01:00
|
|
|
// Get relative path to rootNode
|
|
|
|
QString parentDir = QFileInfo(fn->path()).absolutePath();
|
|
|
|
ProjectExplorer::FolderNode *folder = findOrCreateFolder(rootNode, parentDir);
|
|
|
|
rootNode->addFileNodes(QList<ProjectExplorer::FileNode *>()<< fn, folder);
|
|
|
|
}
|
2009-03-26 17:36:58 +01:00
|
|
|
|
|
|
|
// remove old file nodes and check wheter folder nodes can be removed
|
|
|
|
foreach (ProjectExplorer::FileNode *fn, deleted) {
|
|
|
|
ProjectExplorer::FolderNode *parent = fn->parentFolderNode();
|
|
|
|
// qDebug()<<"removed"<<fn->path();
|
|
|
|
rootNode->removeFileNodes(QList<ProjectExplorer::FileNode *>() << fn, parent);
|
|
|
|
// Check for empty parent
|
|
|
|
while (parent->subFolderNodes().isEmpty() && parent->fileNodes().isEmpty()) {
|
|
|
|
ProjectExplorer::FolderNode *grandparent = parent->parentFolderNode();
|
|
|
|
rootNode->removeFolderNodes(QList<ProjectExplorer::FolderNode *>() << parent, grandparent);
|
|
|
|
parent = grandparent;
|
|
|
|
if (parent == rootNode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *rootNode, QString directory)
|
|
|
|
{
|
|
|
|
QString relativePath = QDir(QFileInfo(rootNode->path()).path()).relativeFilePath(directory);
|
2009-03-03 17:56:03 +01:00
|
|
|
QStringList parts = relativePath.split("/", QString::SkipEmptyParts);
|
2008-12-02 12:01:29 +01:00
|
|
|
ProjectExplorer::FolderNode *parent = rootNode;
|
2009-10-27 17:27:37 +01:00
|
|
|
QString path = QFileInfo(rootNode->path()).path();
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &part, parts) {
|
2009-10-27 17:27:37 +01:00
|
|
|
path += "/" + part;
|
2008-12-02 12:01:29 +01:00
|
|
|
// Find folder in subFolders
|
|
|
|
bool found = false;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) {
|
2009-10-27 17:27:37 +01:00
|
|
|
if (folder->path() == path) {
|
2008-12-02 12:01:29 +01:00
|
|
|
// yeah found something :)
|
|
|
|
parent = folder;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
// No FolderNode yet, so create it
|
2009-10-27 17:27:37 +01:00
|
|
|
ProjectExplorer::FolderNode *tmp = new ProjectExplorer::FolderNode(path);
|
|
|
|
tmp->setFolderName(part);
|
2008-12-02 12:01:29 +01:00
|
|
|
rootNode->addFolderNodes(QList<ProjectExplorer::FolderNode *>() << tmp, parent);
|
|
|
|
parent = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CMakeProject::name() const
|
|
|
|
{
|
2009-01-15 14:48:28 +00:00
|
|
|
return m_projectName;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Core::IFile *CMakeProject::file() const
|
|
|
|
{
|
|
|
|
return m_file;
|
|
|
|
}
|
|
|
|
|
2009-04-20 14:35:25 +02:00
|
|
|
CMakeManager *CMakeProject::projectManager() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
return m_manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<ProjectExplorer::Project *> CMakeProject::dependsOn()
|
|
|
|
{
|
|
|
|
return QList<Project *>();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMakeProject::isApplication() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
ProjectExplorer::BuildConfigWidget *CMakeProject::createConfigWidget()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-12 15:10:33 +01:00
|
|
|
return new CMakeBuildSettingsWidget(this);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
QList<ProjectExplorer::BuildConfigWidget*> CMakeProject::subConfigWidgets()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-08-06 15:31:32 +02:00
|
|
|
QList<ProjectExplorer::BuildConfigWidget*> list;
|
2009-05-26 15:22:11 +02:00
|
|
|
list << new CMakeBuildEnvironmentWidget(this);
|
|
|
|
return list;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::ProjectNode *CMakeProject::rootProjectNode() const
|
|
|
|
{
|
|
|
|
return m_rootNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList CMakeProject::files(FilesMode fileMode) const
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(fileMode)
|
2008-12-02 12:01:29 +01:00
|
|
|
return m_files;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
|
|
|
|
{
|
2008-12-09 14:13:29 +01:00
|
|
|
Project::saveSettingsImpl(writer);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-07-03 16:46:01 +02:00
|
|
|
bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-09 14:13:29 +01:00
|
|
|
Project::restoreSettingsImpl(reader);
|
2009-01-23 16:57:38 +01:00
|
|
|
bool hasUserFile = !buildConfigurations().isEmpty();
|
2009-09-14 13:33:51 +02:00
|
|
|
MakeStep *makeStep = 0;
|
2009-01-23 16:57:38 +01:00
|
|
|
if (!hasUserFile) {
|
|
|
|
// Ask the user for where he wants to build it
|
|
|
|
// and the cmake command line
|
|
|
|
|
2009-05-26 16:10:13 +02:00
|
|
|
CMakeOpenProjectWizard copw(m_manager, sourceDirectory(), ProjectExplorer::Environment::systemEnvironment());
|
2009-11-03 14:37:23 +01:00
|
|
|
if (copw.exec() != QDialog::Accepted)
|
|
|
|
return false;
|
2009-01-23 16:57:38 +01:00
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(this);
|
|
|
|
bc->setDisplayName("all");
|
2009-09-24 16:02:02 +02:00
|
|
|
addBuildConfiguration(bc);
|
2009-09-25 14:29:23 +02:00
|
|
|
bc->setValue("msvcVersion", copw.msvcVersion());
|
2009-03-09 18:13:19 +01:00
|
|
|
if (!copw.buildDirectory().isEmpty())
|
2009-09-25 14:29:23 +02:00
|
|
|
bc->setValue("buildDirectory", copw.buildDirectory());
|
2009-04-07 15:00:16 +02:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
// Now create a standard build configuration
|
2009-11-23 15:47:26 +01:00
|
|
|
makeStep = new MakeStep(bc);
|
2009-10-27 14:16:28 +01:00
|
|
|
bc->insertBuildStep(0, makeStep);
|
|
|
|
|
|
|
|
//TODO save arguments somewhere copw.arguments()
|
2009-11-23 15:47:26 +01:00
|
|
|
MakeStep *cleanMakeStep = new MakeStep(bc);
|
2009-10-27 14:16:28 +01:00
|
|
|
bc->insertCleanStep(0, cleanMakeStep);
|
2009-10-15 19:06:51 +02:00
|
|
|
cleanMakeStep->setClean(true);
|
2009-09-24 16:02:02 +02:00
|
|
|
setActiveBuildConfiguration(bc);
|
2009-03-09 18:13:19 +01:00
|
|
|
} else {
|
|
|
|
// We have a user file, but we could still be missing the cbp file
|
|
|
|
// or simply run createXml with the saved settings
|
2009-03-16 17:33:05 +01:00
|
|
|
QFileInfo sourceFileInfo(m_fileName);
|
2009-09-24 16:02:02 +02:00
|
|
|
BuildConfiguration *activeBC = activeBuildConfiguration();
|
2009-11-25 18:50:20 +01:00
|
|
|
QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory()));
|
2009-05-18 18:07:52 +02:00
|
|
|
QFileInfo cbpFileFi(cbpFile);
|
2009-05-26 15:50:27 +02:00
|
|
|
|
|
|
|
CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing;
|
2009-05-18 18:07:52 +02:00
|
|
|
if (!cbpFileFi.exists())
|
2009-05-26 15:50:27 +02:00
|
|
|
mode = CMakeOpenProjectWizard::NeedToCreate;
|
2009-05-18 18:07:52 +02:00
|
|
|
else if (cbpFileFi.lastModified() < sourceFileInfo.lastModified())
|
2009-05-26 15:50:27 +02:00
|
|
|
mode = CMakeOpenProjectWizard::NeedToUpdate;
|
2009-05-18 18:07:52 +02:00
|
|
|
|
2009-05-26 15:50:27 +02:00
|
|
|
if (mode != CMakeOpenProjectWizard::Nothing) {
|
2009-05-26 16:10:13 +02:00
|
|
|
CMakeOpenProjectWizard copw(m_manager,
|
|
|
|
sourceFileInfo.absolutePath(),
|
2009-11-25 18:50:20 +01:00
|
|
|
activeBC->buildDirectory(),
|
2009-05-26 16:10:13 +02:00
|
|
|
mode,
|
2009-11-25 18:50:20 +01:00
|
|
|
activeBC->environment());
|
2009-11-03 14:37:23 +01:00
|
|
|
if (copw.exec() != QDialog::Accepted)
|
|
|
|
return false;
|
2009-09-24 16:02:02 +02:00
|
|
|
activeBC->setValue("msvcVersion", copw.msvcVersion());
|
2009-03-16 17:33:05 +01:00
|
|
|
}
|
2009-01-23 16:57:38 +01:00
|
|
|
}
|
2009-06-17 11:56:49 +02:00
|
|
|
|
|
|
|
m_watcher = new ProjectExplorer::FileWatcher(this);
|
|
|
|
connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString)));
|
2009-09-14 16:09:17 +02:00
|
|
|
bool result = parseCMakeLists(); // Gets the directory from the active buildconfiguration
|
|
|
|
if (!result)
|
|
|
|
return false;
|
2009-06-17 11:56:49 +02:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
if (!hasUserFile && targets().contains("all"))
|
|
|
|
makeStep->setBuildTarget("all", true);
|
|
|
|
|
2009-06-17 11:56:49 +02:00
|
|
|
connect(this, SIGNAL(activeBuildConfigurationChanged()),
|
|
|
|
this, SLOT(slotActiveBuildConfiguration()));
|
2009-07-03 16:46:01 +02:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-04-06 17:01:26 +02:00
|
|
|
CMakeTarget CMakeProject::targetForTitle(const QString &title)
|
|
|
|
{
|
|
|
|
foreach(const CMakeTarget &ct, m_targets)
|
|
|
|
if (ct.title == title)
|
|
|
|
return ct;
|
|
|
|
return CMakeTarget();
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:56:40 +02:00
|
|
|
// CMakeFile
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
|
|
|
|
: Core::IFile(parent), m_project(parent), m_fileName(fileName)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMakeFile::save(const QString &fileName)
|
|
|
|
{
|
|
|
|
// Once we have an texteditor open for this file, we probably do
|
|
|
|
// need to implement this, don't we.
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(fileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CMakeFile::fileName() const
|
|
|
|
{
|
|
|
|
return m_fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CMakeFile::defaultPath() const
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CMakeFile::suggestedFileName() const
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CMakeFile::mimeType() const
|
|
|
|
{
|
|
|
|
return Constants::CMAKEMIMETYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CMakeFile::isModified() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMakeFile::isReadOnly() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMakeFile::isSaveAsAllowed() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeFile::modified(ReloadBehavior *behavior)
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(behavior)
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 15:10:33 +01:00
|
|
|
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeProject *project)
|
2009-11-24 15:36:31 +01:00
|
|
|
: m_project(project), m_buildConfiguration(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-12 15:10:33 +01:00
|
|
|
QFormLayout *fl = new QFormLayout(this);
|
2009-08-06 17:26:38 +02:00
|
|
|
fl->setContentsMargins(20, -1, 0, -1);
|
2009-07-23 17:00:38 +02:00
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
2009-01-12 15:10:33 +01:00
|
|
|
setLayout(fl);
|
2009-04-20 14:35:25 +02:00
|
|
|
m_pathLineEdit = new QLineEdit(this);
|
|
|
|
m_pathLineEdit->setReadOnly(true);
|
2009-01-12 15:10:33 +01:00
|
|
|
// TODO currently doesn't work
|
|
|
|
// since creating the cbp file also creates makefiles
|
|
|
|
// and then cmake builds in that directory instead of shadow building
|
|
|
|
// We need our own generator for that to work
|
2009-04-20 14:35:25 +02:00
|
|
|
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout();
|
|
|
|
hbox->addWidget(m_pathLineEdit);
|
|
|
|
|
|
|
|
m_changeButton = new QPushButton(this);
|
|
|
|
m_changeButton->setText(tr("&Change"));
|
|
|
|
connect(m_changeButton, SIGNAL(clicked()), this, SLOT(openChangeBuildDirectoryDialog()));
|
|
|
|
hbox->addWidget(m_changeButton);
|
|
|
|
|
|
|
|
fl->addRow("Build directory:", hbox);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString CMakeBuildSettingsWidget::displayName() const
|
|
|
|
{
|
|
|
|
return "CMake";
|
|
|
|
}
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
void CMakeBuildSettingsWidget::init(BuildConfiguration *bc)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-11-25 18:50:20 +01:00
|
|
|
m_buildConfiguration = static_cast<CMakeBuildConfiguration *>(bc);
|
|
|
|
m_pathLineEdit->setText(m_buildConfiguration->buildDirectory());
|
|
|
|
if (m_buildConfiguration->buildDirectory() == m_project->sourceDirectory())
|
2009-04-20 14:35:25 +02:00
|
|
|
m_changeButton->setEnabled(false);
|
|
|
|
else
|
2009-05-18 18:07:52 +02:00
|
|
|
m_changeButton->setEnabled(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2008-12-02 17:56:21 +01:00
|
|
|
|
2009-04-20 14:35:25 +02:00
|
|
|
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-05-26 16:10:13 +02:00
|
|
|
CMakeOpenProjectWizard copw(m_project->projectManager(),
|
|
|
|
m_project->sourceDirectory(),
|
2009-11-25 18:50:20 +01:00
|
|
|
m_buildConfiguration->buildDirectory(),
|
|
|
|
m_buildConfiguration->environment());
|
2009-04-20 14:35:25 +02:00
|
|
|
if (copw.exec() == QDialog::Accepted) {
|
2009-11-24 15:36:31 +01:00
|
|
|
m_project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
|
2009-11-25 18:50:20 +01:00
|
|
|
m_pathLineEdit->setText(m_buildConfiguration->buildDirectory());
|
2009-04-20 14:35:25 +02:00
|
|
|
}
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/////
|
|
|
|
// CMakeCbpParser
|
|
|
|
////
|
|
|
|
|
2008-12-02 17:56:21 +01:00
|
|
|
bool CMakeCbpParser::parseCbpFile(const QString &fileName)
|
|
|
|
{
|
|
|
|
QFile fi(fileName);
|
|
|
|
if (fi.exists() && fi.open(QFile::ReadOnly)) {
|
|
|
|
setDevice(&fi);
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (name() == "CodeBlocks_project_file") {
|
|
|
|
parseCodeBlocks_project_file();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fi.close();
|
|
|
|
m_includeFiles.sort();
|
|
|
|
m_includeFiles.removeDuplicates();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseCodeBlocks_project_file()
|
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if (name() == "Project") {
|
|
|
|
parseProject();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseProject()
|
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
2009-01-15 14:48:28 +00:00
|
|
|
} else if (name() == "Option") {
|
|
|
|
parseOption();
|
2008-12-02 17:56:21 +01:00
|
|
|
} else if (name() == "Unit") {
|
|
|
|
parseUnit();
|
|
|
|
} else if (name() == "Build") {
|
|
|
|
parseBuild();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseBuild()
|
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if (name() == "Target") {
|
|
|
|
parseTarget();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseTarget()
|
|
|
|
{
|
2008-12-08 12:24:31 +01:00
|
|
|
m_targetType = false;
|
2008-12-09 14:13:29 +01:00
|
|
|
m_target.clear();
|
|
|
|
|
|
|
|
if (attributes().hasAttribute("title"))
|
|
|
|
m_target.title = attributes().value("title").toString();
|
2008-12-09 14:33:09 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
2009-01-12 17:51:50 +01:00
|
|
|
if (m_targetType || m_target.title == "all" || m_target.title == "install") {
|
2008-12-09 14:13:29 +01:00
|
|
|
m_targets.append(m_target);
|
2008-12-08 12:24:31 +01:00
|
|
|
}
|
2008-12-02 17:56:21 +01:00
|
|
|
return;
|
|
|
|
} else if (name() == "Compiler") {
|
|
|
|
parseCompiler();
|
2008-12-08 12:24:31 +01:00
|
|
|
} else if (name() == "Option") {
|
|
|
|
parseTargetOption();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseTargetOption()
|
|
|
|
{
|
|
|
|
if (attributes().hasAttribute("output"))
|
2008-12-09 14:13:29 +01:00
|
|
|
m_target.executable = attributes().value("output").toString();
|
2009-01-16 13:47:40 +01:00
|
|
|
else if (attributes().hasAttribute("type") && (attributes().value("type") == "1" || attributes().value("type") == "0"))
|
2008-12-08 12:24:31 +01:00
|
|
|
m_targetType = true;
|
2008-12-09 14:13:29 +01:00
|
|
|
else if (attributes().hasAttribute("working_dir"))
|
|
|
|
m_target.workingDirectory = attributes().value("working_dir").toString();
|
2008-12-09 14:33:09 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-09 14:13:29 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if (name() == "MakeCommand") {
|
|
|
|
parseMakeCommand();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-15 14:48:28 +00:00
|
|
|
QString CMakeCbpParser::projectName() const
|
|
|
|
{
|
|
|
|
return m_projectName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseOption()
|
|
|
|
{
|
|
|
|
if (attributes().hasAttribute("title"))
|
|
|
|
m_projectName = attributes().value("title").toString();
|
2009-01-15 16:06:37 +01:00
|
|
|
|
2009-02-11 12:14:51 +01:00
|
|
|
if (attributes().hasAttribute("compiler"))
|
|
|
|
m_compiler = attributes().value("compiler").toString();
|
|
|
|
|
2009-01-15 16:06:37 +01:00
|
|
|
while (!atEnd()) {
|
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if(isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
2009-01-15 14:48:28 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 14:13:29 +01:00
|
|
|
void CMakeCbpParser::parseMakeCommand()
|
|
|
|
{
|
2008-12-09 14:33:09 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-09 14:13:29 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if (name() == "Build") {
|
|
|
|
parseTargetBuild();
|
|
|
|
} else if (name() == "Clean") {
|
|
|
|
parseTargetClean();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseTargetBuild()
|
|
|
|
{
|
|
|
|
if (attributes().hasAttribute("command"))
|
|
|
|
m_target.makeCommand = attributes().value("command").toString();
|
2008-12-09 14:33:09 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-09 14:13:29 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseTargetClean()
|
|
|
|
{
|
|
|
|
if (attributes().hasAttribute("command"))
|
|
|
|
m_target.makeCleanCommand = attributes().value("command").toString();
|
2008-12-09 14:33:09 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-08 12:24:31 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
2008-12-02 17:56:21 +01:00
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseCompiler()
|
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if (name() == "Add") {
|
|
|
|
parseAdd();
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseAdd()
|
|
|
|
{
|
|
|
|
m_includeFiles.append(attributes().value("directory").toString());
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
|
|
|
return;
|
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeCbpParser::parseUnit()
|
|
|
|
{
|
|
|
|
//qDebug()<<stream.attributes().value("filename");
|
|
|
|
QString fileName = attributes().value("filename").toString();
|
2009-06-30 17:38:27 +02:00
|
|
|
m_parsingCmakeUnit = false;
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!atEnd()) {
|
2008-12-02 17:56:21 +01:00
|
|
|
readNext();
|
|
|
|
if (isEndElement()) {
|
2009-06-30 17:38:27 +02:00
|
|
|
if (!fileName.endsWith(".rule") && !m_processedUnits.contains(fileName)) {
|
|
|
|
// Now check whether we found a virtual element beneath
|
2009-07-27 12:20:16 +02:00
|
|
|
if (m_parsingCmakeUnit) {
|
2009-06-30 17:38:27 +02:00
|
|
|
m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false));
|
2009-07-27 12:20:16 +02:00
|
|
|
} else {
|
|
|
|
if (fileName.endsWith(".qrc"))
|
|
|
|
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ResourceType, false));
|
|
|
|
else
|
|
|
|
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, false));
|
|
|
|
}
|
2009-06-30 17:38:27 +02:00
|
|
|
m_processedUnits.insert(fileName);
|
|
|
|
}
|
2008-12-02 17:56:21 +01:00
|
|
|
return;
|
2009-06-30 17:38:27 +02:00
|
|
|
} else if (name() == "Option") {
|
|
|
|
parseUnitOption();
|
2008-12-02 17:56:21 +01:00
|
|
|
} else if (isStartElement()) {
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 17:38:27 +02:00
|
|
|
void CMakeCbpParser::parseUnitOption()
|
|
|
|
{
|
|
|
|
if (attributes().hasAttribute("virtualFolder"))
|
|
|
|
m_parsingCmakeUnit = true;
|
|
|
|
|
|
|
|
while (!atEnd()) {
|
|
|
|
readNext();
|
|
|
|
|
|
|
|
if (isEndElement())
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (isStartElement())
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-02 17:56:21 +01:00
|
|
|
void CMakeCbpParser::parseUnknownElement()
|
|
|
|
{
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(isStartElement());
|
2008-12-02 17:56:21 +01:00
|
|
|
|
|
|
|
while (!atEnd()) {
|
|
|
|
readNext();
|
|
|
|
|
|
|
|
if (isEndElement())
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (isStartElement())
|
|
|
|
parseUnknownElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<ProjectExplorer::FileNode *> CMakeCbpParser::fileList()
|
|
|
|
{
|
|
|
|
return m_fileList;
|
|
|
|
}
|
|
|
|
|
2009-06-30 17:38:27 +02:00
|
|
|
QList<ProjectExplorer::FileNode *> CMakeCbpParser::cmakeFileList()
|
|
|
|
{
|
|
|
|
return m_cmakeFileList;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMakeCbpParser::hasCMakeFiles()
|
|
|
|
{
|
|
|
|
return !m_cmakeFileList.isEmpty();
|
|
|
|
}
|
|
|
|
|
2008-12-02 17:56:21 +01:00
|
|
|
QStringList CMakeCbpParser::includeFiles()
|
|
|
|
{
|
|
|
|
return m_includeFiles;
|
|
|
|
}
|
2008-12-09 14:13:29 +01:00
|
|
|
|
|
|
|
QList<CMakeTarget> CMakeCbpParser::targets()
|
|
|
|
{
|
|
|
|
return m_targets;
|
|
|
|
}
|
|
|
|
|
2009-02-11 12:14:51 +01:00
|
|
|
QString CMakeCbpParser::compilerName() const
|
|
|
|
{
|
|
|
|
return m_compiler;
|
|
|
|
}
|
|
|
|
|
2008-12-09 14:13:29 +01:00
|
|
|
void CMakeTarget::clear()
|
|
|
|
{
|
|
|
|
executable = QString::null;
|
|
|
|
makeCommand = QString::null;
|
|
|
|
makeCleanCommand = QString::null;
|
|
|
|
workingDirectory = QString::null;
|
|
|
|
title = QString::null;
|
|
|
|
}
|
|
|
|
|