2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02: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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02: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"
|
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>
|
2009-09-24 16:02:02 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2012-11-08 18:02:50 +01:00
|
|
|
#include <projectexplorer/namedwidget.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
|
|
|
|
|
|
2012-10-16 17:19:59 +02:00
|
|
|
namespace ProjectExplorer { class Target; }
|
|
|
|
|
|
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-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
|
|
|
|
2013-01-17 15:12:46 +01:00
|
|
|
QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k,
|
|
|
|
|
const QString &bcName);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-09-24 13:17:43 +02:00
|
|
|
QString uicCommand() const;
|
|
|
|
|
|
2011-03-31 17:43:48 +02:00
|
|
|
bool isProjectFile(const QString &fileName);
|
|
|
|
|
|
2012-07-17 15:56:43 +02:00
|
|
|
bool parseCMakeLists();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
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);
|
2012-10-02 17:46:19 +02:00
|
|
|
bool setupTarget(ProjectExplorer::Target *t);
|
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);
|
2012-10-16 17:19:59 +02:00
|
|
|
void activeTargetWasChanged(ProjectExplorer::Target *target);
|
2010-02-08 15:50:06 +01:00
|
|
|
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
|
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);
|
2012-07-17 15:56:43 +02:00
|
|
|
void updateRunConfigurations();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-07-17 15:56:43 +02:00
|
|
|
private:
|
2008-12-02 12:01:29 +01:00
|
|
|
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);
|
2012-04-24 15:49:09 +02:00
|
|
|
void updateRunConfigurations(ProjectExplorer::Target *t);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
CMakeManager *m_manager;
|
2012-10-16 17:19:59 +02:00
|
|
|
ProjectExplorer::Target *m_activeTarget;
|
2008-12-02 12:01:29 +01:00
|
|
|
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();
|
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();
|
2013-01-01 18:18:03 +01:00
|
|
|
void parseMakeCommands();
|
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;
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2012-11-08 18:02:50 +01:00
|
|
|
class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget
|
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:
|
2012-11-08 17:35:59 +01:00
|
|
|
CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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:
|
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
|