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-06-17 00:01:27 +10:00
|
|
|
** contact the sales department at http://www.qtsoftware.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
|
|
|
#ifndef CMAKEPROJECT_H
|
|
|
|
|
#define CMAKEPROJECT_H
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
#include "cmakeprojectmanager.h"
|
|
|
|
|
#include "cmakeprojectnodes.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-02-11 12:14:51 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2009-03-26 17:36:58 +01:00
|
|
|
#include <projectexplorer/filewatcher.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/ifile.h>
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
#include <QtCore/QXmlStreamReader>
|
2009-04-20 14:35:25 +02:00
|
|
|
#include <QtGui/QPushButton>
|
|
|
|
|
#include <QtGui/QLineEdit>
|
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;
|
|
|
|
|
|
2008-12-09 14:13:29 +01:00
|
|
|
struct CMakeTarget
|
|
|
|
|
{
|
|
|
|
|
QString title;
|
|
|
|
|
QString executable;
|
|
|
|
|
QString workingDirectory;
|
|
|
|
|
QString makeCommand;
|
|
|
|
|
QString makeCleanCommand;
|
|
|
|
|
void clear();
|
|
|
|
|
};
|
|
|
|
|
|
2009-04-20 14:35:25 +02:00
|
|
|
class CMakeBuildSettingsWidget;
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
virtual QString name() const;
|
|
|
|
|
virtual Core::IFile *file() const;
|
2009-04-20 14:35:25 +02:00
|
|
|
virtual CMakeManager *projectManager() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
virtual QList<ProjectExplorer::Project *> dependsOn(); //NBS TODO implement dependsOn
|
|
|
|
|
|
|
|
|
|
virtual bool isApplication() const;
|
|
|
|
|
|
2009-05-26 15:22:11 +02:00
|
|
|
//building environment
|
|
|
|
|
ProjectExplorer::Environment environment(const QString &buildConfiguration) const;
|
|
|
|
|
ProjectExplorer::Environment baseEnvironment(const QString &buildConfiguration) const;
|
|
|
|
|
void setUserEnvironmentChanges(const QString &buildConfig, const QList<ProjectExplorer::EnvironmentItem> &diff);
|
|
|
|
|
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges(const QString &buildConfig) const;
|
|
|
|
|
bool useSystemEnvironment(const QString &buildConfiguration) const;
|
|
|
|
|
void setUseSystemEnvironment(const QString &buildConfiguration, bool b);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual QString buildDirectory(const QString &buildConfiguration) const;
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
virtual ProjectExplorer::BuildConfigWidget *createConfigWidget();
|
|
|
|
|
virtual QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// This method is called for new build configurations
|
|
|
|
|
// You should probably set some default values in this method
|
|
|
|
|
virtual void newBuildConfiguration(const QString &buildConfiguration);
|
|
|
|
|
|
|
|
|
|
virtual ProjectExplorer::ProjectNode *rootProjectNode() const;
|
|
|
|
|
|
|
|
|
|
virtual QStringList files(FilesMode fileMode) const;
|
2009-01-12 15:10:33 +01:00
|
|
|
MakeStep *makeStep() const;
|
|
|
|
|
QStringList targets() const;
|
2009-02-16 13:12:12 +01:00
|
|
|
QString buildParser(const QString &buildConfiguration) const;
|
2009-04-06 17:01:26 +02:00
|
|
|
CMakeTarget targetForTitle(const QString &title);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-04-20 14:35:25 +02:00
|
|
|
QString sourceDirectory() const;
|
2009-06-17 17:56:40 +02:00
|
|
|
ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
|
2009-07-02 16:44:51 +02:00
|
|
|
ProjectExplorer::ToolChain *toolChain(const QString &buildConfiguration) const;
|
2009-04-20 14:35:25 +02:00
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
protected:
|
|
|
|
|
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
|
2009-07-03 16:46:01 +02:00
|
|
|
virtual bool restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
|
2009-03-26 17:36:58 +01:00
|
|
|
|
2009-04-20 14:35:25 +02:00
|
|
|
// called by CMakeBuildSettingsWidget
|
|
|
|
|
void changeBuildDirectory(const QString &buildConfiguration, const QString &newBuildDirectory);
|
|
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
private slots:
|
|
|
|
|
void fileChanged(const QString &fileName);
|
2009-05-18 18:07:52 +02:00
|
|
|
void slotActiveBuildConfiguration();
|
2009-03-26 17:36:58 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2009-07-03 16:46:01 +02:00
|
|
|
bool parseCMakeLists();
|
2009-03-26 17:36:58 +01:00
|
|
|
void updateToolChain(const QString &compiler);
|
2008-12-02 17:56:21 +01:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
CMakeManager *m_manager;
|
|
|
|
|
QString m_fileName;
|
|
|
|
|
CMakeFile *m_file;
|
2009-01-15 14:48:28 +00:00
|
|
|
QString m_projectName;
|
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;
|
2008-12-09 14:13:29 +01:00
|
|
|
QList<CMakeTarget> m_targets;
|
2009-02-11 12:14:51 +01:00
|
|
|
ProjectExplorer::ToolChain *m_toolChain;
|
2009-03-26 17:36:58 +01:00
|
|
|
ProjectExplorer::FileWatcher *m_watcher;
|
|
|
|
|
bool m_insideFileChanged;
|
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();
|
2008-12-09 14:13:29 +01:00
|
|
|
QList<CMakeTarget> targets();
|
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();
|
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();
|
2008-12-02 17:56:21 +01:00
|
|
|
void parseTarget();
|
2008-12-08 12:24:31 +01:00
|
|
|
void parseTargetOption();
|
2008-12-09 14:13:29 +01:00
|
|
|
void parseMakeCommand();
|
|
|
|
|
void parseTargetBuild();
|
|
|
|
|
void parseTargetClean();
|
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;
|
2008-12-08 12:24:31 +01:00
|
|
|
|
2008-12-09 14:13:29 +01:00
|
|
|
CMakeTarget m_target;
|
2008-12-08 12:24:31 +01:00
|
|
|
bool m_targetType;
|
2008-12-09 14:13:29 +01:00
|
|
|
QList<CMakeTarget> m_targets;
|
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
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class CMakeFile : public Core::IFile
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
CMakeFile(CMakeProject *parent, QString fileName);
|
|
|
|
|
|
|
|
|
|
bool save(const QString &fileName = QString());
|
|
|
|
|
QString fileName() const;
|
|
|
|
|
|
|
|
|
|
QString defaultPath() const;
|
|
|
|
|
QString suggestedFileName() const;
|
|
|
|
|
QString mimeType() const;
|
|
|
|
|
|
|
|
|
|
bool isModified() const;
|
|
|
|
|
bool isReadOnly() const;
|
|
|
|
|
bool isSaveAsAllowed() const;
|
|
|
|
|
|
|
|
|
|
void modified(ReloadBehavior *behavior);
|
|
|
|
|
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:
|
2009-01-12 15:10:33 +01:00
|
|
|
CMakeBuildSettingsWidget(CMakeProject *project);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual QString displayName() const;
|
|
|
|
|
|
|
|
|
|
// This is called to set up the config widget before showing it
|
|
|
|
|
// buildConfiguration is QString::null for the non buildConfiguration specific page
|
|
|
|
|
virtual void init(const QString &buildConfiguration);
|
2009-01-12 15:10:33 +01:00
|
|
|
private slots:
|
2009-04-20 14:35:25 +02:00
|
|
|
void openChangeBuildDirectoryDialog();
|
2009-01-12 15:10:33 +01:00
|
|
|
private:
|
|
|
|
|
CMakeProject *m_project;
|
2009-04-20 14:35:25 +02:00
|
|
|
QLineEdit *m_pathLineEdit;
|
|
|
|
|
QPushButton *m_changeButton;
|
2009-01-12 15:10:33 +01:00
|
|
|
QString 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
|