2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
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
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
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
|
|
|
#ifndef CMAKEPROJECT_H
|
|
|
|
|
#define CMAKEPROJECT_H
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
#include "cmakeprojectmanager.h"
|
|
|
|
|
#include "cmakeprojectnodes.h"
|
2009-11-25 18:50:20 +01:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "cmaketarget.h"
|
2009-01-12 15:10:33 +01:00
|
|
|
#include "makestep.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/projectnodes.h>
|
|
|
|
|
#include <projectexplorer/buildstep.h>
|
2009-09-24 16:02:02 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2011-03-31 17:43:48 +02:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2010-09-24 13:17:43 +02:00
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QXmlStreamReader>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QLineEdit>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-03-26 17:31:04 +04:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QFileSystemWatcher;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace CMakeProjectManager {
|
2009-03-18 14:35:35 +01:00
|
|
|
namespace Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
class CMakeFile;
|
2009-09-24 16:02:02 +02:00
|
|
|
class CMakeBuildSettingsWidget;
|
2010-09-24 13:17:43 +02:00
|
|
|
class CMakeUiCodeModelSupport;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
struct CMakeBuildTarget
|
2008-12-09 14:13:29 +01:00
|
|
|
{
|
|
|
|
|
QString title;
|
2010-04-23 16:24:55 +02:00
|
|
|
QString executable; // TODO: rename to output?
|
|
|
|
|
bool library;
|
2008-12-09 14:13:29 +01:00
|
|
|
QString workingDirectory;
|
|
|
|
|
QString makeCommand;
|
|
|
|
|
QString makeCleanCommand;
|
|
|
|
|
void clear();
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class CMakeProject : public ProjectExplorer::Project
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2009-04-20 14:35:25 +02:00
|
|
|
// for changeBuildDirectory
|
|
|
|
|
friend class CMakeBuildSettingsWidget;
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
|
|
|
|
CMakeProject(CMakeManager *manager, const QString &filename);
|
|
|
|
|
~CMakeProject();
|
|
|
|
|
|
2010-02-02 11:32:39 +01:00
|
|
|
QString displayName() const;
|
2012-03-15 17:17:40 +01:00
|
|
|
Core::Id id() const;
|
2012-02-14 16:43:51 +01:00
|
|
|
Core::IDocument *document() const;
|
2010-02-02 11:32:39 +01:00
|
|
|
CMakeManager *projectManager() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
CMakeTarget *activeTarget() const;
|
|
|
|
|
|
2010-02-02 11:32:39 +01:00
|
|
|
QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-02 11:32:39 +01:00
|
|
|
ProjectExplorer::ProjectNode *rootProjectNode() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-02 11:32:39 +01:00
|
|
|
QStringList files(FilesMode fileMode) const;
|
2010-02-02 12:01:11 +01:00
|
|
|
QStringList buildTargetTitles() const;
|
|
|
|
|
QList<CMakeBuildTarget> buildTargets() const;
|
|
|
|
|
bool hasBuildTarget(const QString &title) const;
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
CMakeBuildTarget buildTargetForTitle(const QString &title);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-25 11:55:49 +01:00
|
|
|
QString defaultBuildDirectory() const;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool parseCMakeLists();
|
|
|
|
|
|
2010-09-24 13:17:43 +02:00
|
|
|
QString uicCommand() const;
|
|
|
|
|
|
2011-03-31 17:43:48 +02:00
|
|
|
bool isProjectFile(const QString &fileName);
|
|
|
|
|
|
2009-12-03 19:45:09 +01:00
|
|
|
signals:
|
|
|
|
|
/// emitted after parsing
|
2010-02-02 12:01:11 +01:00
|
|
|
void buildTargetsChanged();
|
2009-12-03 19:45:09 +01:00
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
protected:
|
2010-02-02 11:32:39 +01:00
|
|
|
bool fromMap(const QVariantMap &map);
|
2009-03-26 17:36:58 +01:00
|
|
|
|
2009-04-20 14:35:25 +02:00
|
|
|
// called by CMakeBuildSettingsWidget
|
2009-12-03 19:45:09 +01:00
|
|
|
void changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory);
|
2009-04-20 14:35:25 +02:00
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
private slots:
|
|
|
|
|
void fileChanged(const QString &fileName);
|
2010-02-08 15:50:06 +01:00
|
|
|
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
|
|
|
|
|
void targetAdded(ProjectExplorer::Target *);
|
2009-03-26 17:36:58 +01:00
|
|
|
|
2010-09-24 13:17:43 +02:00
|
|
|
void editorChanged(Core::IEditor *editor);
|
|
|
|
|
void editorAboutToClose(Core::IEditor *editor);
|
|
|
|
|
void uiEditorContentsChanged();
|
|
|
|
|
void buildStateChanged(ProjectExplorer::Project *project);
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
|
2009-03-26 17:36:58 +01:00
|
|
|
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
|
2008-12-02 12:01:29 +01:00
|
|
|
ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory);
|
2010-09-24 13:17:43 +02:00
|
|
|
void updateCodeModelSupportFromEditor(const QString &uiFileName, const QString &contents);
|
|
|
|
|
void createUiCodeModelSupport();
|
|
|
|
|
QString uiHeaderFile(const QString &uiFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
CMakeManager *m_manager;
|
|
|
|
|
QString m_fileName;
|
|
|
|
|
CMakeFile *m_file;
|
2009-01-15 14:48:28 +00:00
|
|
|
QString m_projectName;
|
2010-09-24 13:17:43 +02:00
|
|
|
QString m_uicCommand;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// TODO probably need a CMake specific node structure
|
2009-03-18 12:18:59 +01:00
|
|
|
CMakeProjectNode *m_rootNode;
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList m_files;
|
2010-02-02 12:01:11 +01:00
|
|
|
QList<CMakeBuildTarget> m_buildTargets;
|
2011-03-31 17:43:48 +02:00
|
|
|
QFileSystemWatcher *m_watcher;
|
2009-09-14 16:09:17 +02:00
|
|
|
QSet<QString> m_watchedFiles;
|
2010-04-22 18:57:43 +02:00
|
|
|
QFuture<void> m_codeModelFuture;
|
2010-09-24 13:17:43 +02:00
|
|
|
|
|
|
|
|
QMap<QString, CMakeUiCodeModelSupport *> m_uiCodeModelSupport;
|
|
|
|
|
Core::IEditor *m_lastEditor;
|
|
|
|
|
bool m_dirtyUic;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 17:56:21 +01:00
|
|
|
class CMakeCbpParser : public QXmlStreamReader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool parseCbpFile(const QString &fileName);
|
|
|
|
|
QList<ProjectExplorer::FileNode *> fileList();
|
2009-06-30 17:38:27 +02:00
|
|
|
QList<ProjectExplorer::FileNode *> cmakeFileList();
|
2008-12-02 17:56:21 +01:00
|
|
|
QStringList includeFiles();
|
2010-02-02 12:01:11 +01:00
|
|
|
QList<CMakeBuildTarget> buildTargets();
|
2012-05-26 21:05:30 +02:00
|
|
|
QByteArray defines() const;
|
2009-01-15 14:48:28 +00:00
|
|
|
QString projectName() const;
|
2009-02-11 12:14:51 +01:00
|
|
|
QString compilerName() const;
|
2009-06-30 17:38:27 +02:00
|
|
|
bool hasCMakeFiles();
|
2012-05-26 21:05:30 +02:00
|
|
|
|
2008-12-02 17:56:21 +01:00
|
|
|
private:
|
|
|
|
|
void parseCodeBlocks_project_file();
|
|
|
|
|
void parseProject();
|
|
|
|
|
void parseBuild();
|
2009-01-15 14:48:28 +00:00
|
|
|
void parseOption();
|
2010-02-02 12:01:11 +01:00
|
|
|
void parseBuildTarget();
|
|
|
|
|
void parseBuildTargetOption();
|
2008-12-09 14:13:29 +01:00
|
|
|
void parseMakeCommand();
|
2010-02-02 12:01:11 +01:00
|
|
|
void parseBuildTargetBuild();
|
|
|
|
|
void parseBuildTargetClean();
|
2008-12-02 17:56:21 +01:00
|
|
|
void parseCompiler();
|
|
|
|
|
void parseAdd();
|
|
|
|
|
void parseUnit();
|
2009-06-30 17:38:27 +02:00
|
|
|
void parseUnitOption();
|
2008-12-02 17:56:21 +01:00
|
|
|
void parseUnknownElement();
|
|
|
|
|
|
|
|
|
|
QList<ProjectExplorer::FileNode *> m_fileList;
|
2009-06-30 17:38:27 +02:00
|
|
|
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
|
|
|
|
|
QSet<QString> m_processedUnits;
|
|
|
|
|
bool m_parsingCmakeUnit;
|
2008-12-02 17:56:21 +01:00
|
|
|
QStringList m_includeFiles;
|
2012-05-26 21:05:30 +02:00
|
|
|
QStringList m_compilerOptions;
|
|
|
|
|
QByteArray m_defines;
|
2008-12-08 12:24:31 +01:00
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
CMakeBuildTarget m_buildTarget;
|
|
|
|
|
bool m_buildTargetType;
|
|
|
|
|
QList<CMakeBuildTarget> m_buildTargets;
|
2009-01-15 14:48:28 +00:00
|
|
|
QString m_projectName;
|
2009-02-11 12:14:51 +01:00
|
|
|
QString m_compiler;
|
2008-12-02 17:56:21 +01:00
|
|
|
};
|
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
class CMakeFile : public Core::IDocument
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
CMakeFile(CMakeProject *parent, QString fileName);
|
|
|
|
|
|
2011-05-10 20:43:03 +02:00
|
|
|
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
2008-12-02 12:01:29 +01:00
|
|
|
QString fileName() const;
|
|
|
|
|
|
|
|
|
|
QString defaultPath() const;
|
|
|
|
|
QString suggestedFileName() const;
|
|
|
|
|
QString mimeType() const;
|
|
|
|
|
|
|
|
|
|
bool isModified() const;
|
|
|
|
|
bool isSaveAsAllowed() const;
|
|
|
|
|
|
2010-03-19 10:28:05 +01:00
|
|
|
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
2011-04-04 15:24:13 +02:00
|
|
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
2010-03-19 10:28:05 +01:00
|
|
|
|
2010-05-11 14:13:38 +02:00
|
|
|
void rename(const QString &newName);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
CMakeProject *m_project;
|
|
|
|
|
QString m_fileName;
|
|
|
|
|
};
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
class CMakeBuildSettingsWidget : public ProjectExplorer::BuildConfigWidget
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-12 15:10:33 +01:00
|
|
|
Q_OBJECT
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2010-12-06 12:45:05 +01:00
|
|
|
explicit CMakeBuildSettingsWidget(CMakeTarget *target);
|
2010-02-02 11:32:39 +01:00
|
|
|
QString displayName() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// This is called to set up the config widget before showing it
|
2009-11-24 15:36:31 +01:00
|
|
|
virtual void init(ProjectExplorer::BuildConfiguration *bc);
|
2009-01-12 15:10:33 +01:00
|
|
|
private slots:
|
2009-04-20 14:35:25 +02:00
|
|
|
void openChangeBuildDirectoryDialog();
|
2010-09-02 13:57:14 +02:00
|
|
|
void runCMake();
|
2009-01-12 15:10:33 +01:00
|
|
|
private:
|
2010-12-06 12:45:05 +01:00
|
|
|
CMakeTarget *m_target;
|
2009-04-20 14:35:25 +02:00
|
|
|
QLineEdit *m_pathLineEdit;
|
|
|
|
|
QPushButton *m_changeButton;
|
2009-11-25 18:50:20 +01:00
|
|
|
CMakeBuildConfiguration *m_buildConfiguration;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CMakeProjectManager
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#endif // CMAKEPROJECT_H
|