Files
qt-creator/src/plugins/cmakeprojectmanager/cmakeproject.h

248 lines
8.0 KiB
C
Raw Normal View History

/**************************************************************************
2008-12-02 12:01:29 +01:00
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2008-12-02 12:01:29 +01:00
**
** Contact: Nokia Corporation (qt-info@nokia.com)
2008-12-02 12:01:29 +01:00
**
** Commercial Usage
**
** 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.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** 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
**
**************************************************************************/
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"
#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>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/filewatcher.h>
#include <projectexplorer/buildconfiguration.h>
2008-12-02 12:01:29 +01:00
#include <coreplugin/ifile.h>
2008-12-02 14:09:21 +01:00
#include <QtCore/QXmlStreamReader>
#include <QtGui/QPushButton>
#include <QtGui/QLineEdit>
2008-12-02 12:01:29 +01:00
namespace CMakeProjectManager {
namespace Internal {
2008-12-02 12:01:29 +01:00
class CMakeFile;
class CMakeBuildSettingsWidget;
2008-12-02 12:01:29 +01:00
struct CMakeTarget
{
QString title;
QString executable;
QString workingDirectory;
QString makeCommand;
QString makeCleanCommand;
void clear();
};
class CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
{
Q_OBJECT
public:
CMakeBuildConfigurationFactory(CMakeProject *project);
~CMakeBuildConfigurationFactory();
QStringList availableCreationTypes() const;
QString displayNameForType(const QString &type) const;
bool create(const QString &type) const;
bool clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
private:
CMakeProject *m_project;
};
2008-12-02 12:01:29 +01:00
class CMakeProject : public ProjectExplorer::Project
{
Q_OBJECT
// 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;
virtual ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const;
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;
//building environment
ProjectExplorer::Environment environment(ProjectExplorer::BuildConfiguration *configuration) const;
ProjectExplorer::Environment baseEnvironment(ProjectExplorer::BuildConfiguration *configuration) const;
void setUserEnvironmentChanges(ProjectExplorer::BuildConfiguration *configuration, const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges(ProjectExplorer::BuildConfiguration *configuration) const;
bool useSystemEnvironment(ProjectExplorer::BuildConfiguration *configuration) const;
void setUseSystemEnvironment(ProjectExplorer::BuildConfiguration *configuration, bool b);
virtual QString buildDirectory(ProjectExplorer::BuildConfiguration *configuration) const;
2008-12-02 12:01:29 +01:00
virtual ProjectExplorer::BuildConfigWidget *createConfigWidget();
virtual QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
2008-12-02 12:01:29 +01:00
virtual ProjectExplorer::ProjectNode *rootProjectNode() const;
virtual QStringList files(FilesMode fileMode) const;
QStringList targets() const;
QString buildParser(ProjectExplorer::BuildConfiguration *configuration) const;
CMakeTarget targetForTitle(const QString &title);
2008-12-02 12:01:29 +01:00
QString sourceDirectory() const;
ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
ProjectExplorer::ToolChain *toolChain(ProjectExplorer::BuildConfiguration *configuration) const;
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
virtual bool restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
// called by CMakeBuildSettingsWidget
void changeBuildDirectory(ProjectExplorer::BuildConfiguration *configuration, const QString &newBuildDirectory);
private slots:
void fileChanged(const QString &fileName);
void slotActiveBuildConfiguration();
2008-12-02 12:01:29 +01:00
private:
2009-09-30 18:36:31 +02:00
bool parseCMakeLists();
void updateToolChain(const QString &compiler);
2008-12-02 12:01:29 +01:00
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
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;
QString m_projectName;
CMakeBuildConfigurationFactory *m_buildConfigurationFactory;
2008-12-02 12:01:29 +01:00
// TODO probably need a CMake specific node structure
CMakeProjectNode *m_rootNode;
2008-12-02 12:01:29 +01:00
QStringList m_files;
QList<CMakeTarget> m_targets;
ProjectExplorer::ToolChain *m_toolChain;
ProjectExplorer::FileWatcher *m_watcher;
bool m_insideFileChanged;
QSet<QString> m_watchedFiles;
2009-09-30 18:36:31 +02:00
friend class CMakeBuildConfigurationFactory; // for parseCMakeLists
2008-12-02 12:01:29 +01:00
};
class CMakeCbpParser : public QXmlStreamReader
{
public:
bool parseCbpFile(const QString &fileName);
QList<ProjectExplorer::FileNode *> fileList();
QList<ProjectExplorer::FileNode *> cmakeFileList();
QStringList includeFiles();
QList<CMakeTarget> targets();
QString projectName() const;
QString compilerName() const;
bool hasCMakeFiles();
private:
void parseCodeBlocks_project_file();
void parseProject();
void parseBuild();
void parseOption();
void parseTarget();
void parseTargetOption();
void parseMakeCommand();
void parseTargetBuild();
void parseTargetClean();
void parseCompiler();
void parseAdd();
void parseUnit();
void parseUnitOption();
void parseUnknownElement();
QList<ProjectExplorer::FileNode *> m_fileList;
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
QSet<QString> m_processedUnits;
bool m_parsingCmakeUnit;
QStringList m_includeFiles;
CMakeTarget m_target;
bool m_targetType;
QList<CMakeTarget> m_targets;
QString m_projectName;
QString m_compiler;
};
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;
};
class CMakeBuildSettingsWidget : public ProjectExplorer::BuildConfigWidget
2008-12-02 12:01:29 +01:00
{
Q_OBJECT
2008-12-02 12:01:29 +01:00
public:
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);
private slots:
void openChangeBuildDirectoryDialog();
private:
CMakeProject *m_project;
QLineEdit *m_pathLineEdit;
QPushButton *m_changeButton;
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