diff options
Diffstat (limited to 'src/plugins/cmakeprojectmanager')
31 files changed, 687 insertions, 529 deletions
diff --git a/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec.in b/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec.in index e51e6eebdb..6388460f83 100644 --- a/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec.in +++ b/src/plugins/cmakeprojectmanager/CMakeProjectManager.pluginspec.in @@ -1,4 +1,4 @@ -<plugin name=\"CMakeProjectManager\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\"> +<plugin name=\"CMakeProjectManager\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_COMPAT_VERSION\"> <vendor>Digia Plc</vendor> <copyright>(C) 2013 Digia Plc</copyright> <license> diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 77e03a45be..9d7179dc6c 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -29,22 +29,26 @@ #include "cmakebuildconfiguration.h" +#include "cmakebuildinfo.h" #include "cmakeopenprojectwizard.h" #include "cmakeproject.h" #include "cmakeprojectconstants.h" +#include <coreplugin/icore.h> +#include <coreplugin/mimedatabase.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/kit.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> +#include <utils/qtcassert.h> + #include <QInputDialog> using namespace CMakeProjectManager; using namespace Internal; namespace { -const char BUILD_DIRECTORY_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory"; const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNinja"; } // namespace @@ -52,15 +56,14 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)), m_useNinja(false) { CMakeProject *project = static_cast<CMakeProject *>(parent->project()); - m_buildDirectory = project->shadowBuildDirectory(project->document()->fileName(), - parent->kit(), - displayName()); + setBuildDirectory(Utils::FileName::fromString(project->shadowBuildDirectory(project->projectFilePath(), + parent->kit(), + displayName()))); } CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent, CMakeBuildConfiguration *source) : BuildConfiguration(parent, source), - m_buildDirectory(source->m_buildDirectory), m_msvcVersion(source->m_msvcVersion), m_useNinja(false) { @@ -71,7 +74,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent QVariantMap CMakeBuildConfiguration::toMap() const { QVariantMap map(ProjectExplorer::BuildConfiguration::toMap()); - map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory); map.insert(QLatin1String(USE_NINJA_KEY), m_useNinja); return map; } @@ -81,7 +83,6 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map) if (!BuildConfiguration::fromMap(map)) return false; - m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString(); m_useNinja = map.value(QLatin1String(USE_NINJA_KEY), false).toBool(); return true; @@ -108,20 +109,6 @@ ProjectExplorer::NamedWidget *CMakeBuildConfiguration::createConfigWidget() return new CMakeBuildSettingsWidget(this); } -QString CMakeBuildConfiguration::buildDirectory() const -{ - return m_buildDirectory; -} - -void CMakeBuildConfiguration::setBuildDirectory(const QString &buildDirectory) -{ - if (m_buildDirectory == buildDirectory) - return; - m_buildDirectory = buildDirectory; - emit buildDirectoryChanged(); - emit environmentChanged(); -} - /*! \class CMakeBuildConfigurationFactory */ @@ -135,64 +122,68 @@ CMakeBuildConfigurationFactory::~CMakeBuildConfigurationFactory() { } -QList<Core::Id> CMakeBuildConfigurationFactory::availableCreationIds(const ProjectExplorer::Target *parent) const +bool CMakeBuildConfigurationFactory::canCreate(const ProjectExplorer::Target *parent) const { - if (!canHandle(parent)) - return QList<Core::Id>(); - return QList<Core::Id>() << Core::Id(Constants::CMAKE_BC_ID); + return canHandle(parent); } -QString CMakeBuildConfigurationFactory::displayNameForId(const Core::Id id) const +QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableBuilds(const ProjectExplorer::Target *parent) const { - if (id == Constants::CMAKE_BC_ID) - return tr("Build"); - return QString(); + QList<ProjectExplorer::BuildInfo *> result; + QTC_ASSERT(canCreate(parent), return result); + + CMakeBuildInfo *info = createBuildInfo(parent->kit(), + parent->project()->projectDirectory()); + result << info; + return result; } -bool CMakeBuildConfigurationFactory::canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const +bool CMakeBuildConfigurationFactory::canSetup(const ProjectExplorer::Kit *k, const QString &projectPath) const { - if (!canHandle(parent)) - return false; - if (id == Constants::CMAKE_BC_ID) - return true; - return false; + return k && Core::MimeDatabase::findByFile(QFileInfo(projectPath)) + .matchesType(QLatin1String(Constants::CMAKEMIMETYPE)); } -CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name) +QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableSetups(const ProjectExplorer::Kit *k, + const QString &projectPath) const { - if (!canCreate(parent, id)) - return 0; + QList<ProjectExplorer::BuildInfo *> result; + QTC_ASSERT(canSetup(k, projectPath), return result); + + CMakeBuildInfo *info = createBuildInfo(k, ProjectExplorer::Project::projectDirectory(projectPath)); + //: The name of the build configuration created by default for a cmake project. + info->displayName = tr("Default"); + info->buildDirectory + = Utils::FileName::fromString(CMakeProject::shadowBuildDirectory(projectPath, k, + info->displayName)); + result << info; + return result; +} + +ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer::Target *parent, + const ProjectExplorer::BuildInfo *info) const +{ + QTC_ASSERT(canCreate(parent), return 0); + QTC_ASSERT(info->factory() == this, return 0); + QTC_ASSERT(info->kitId == parent->kit()->id(), return 0); + QTC_ASSERT(!info->displayName.isEmpty(), return 0); + CMakeBuildInfo copy(*static_cast<const CMakeBuildInfo *>(info)); CMakeProject *project = static_cast<CMakeProject *>(parent->project()); - bool ok = true; - QString buildConfigurationName = name; - if (buildConfigurationName.isNull()) - buildConfigurationName = QInputDialog::getText(0, - tr("New Configuration"), - tr("New configuration name:"), - QLineEdit::Normal, - QString(), &ok); - buildConfigurationName = buildConfigurationName.trimmed(); - if (!ok || buildConfigurationName.isEmpty()) - return 0; + if (copy.buildDirectory.isEmpty()) + copy.buildDirectory + = Utils::FileName::fromString(project->shadowBuildDirectory(project->projectFilePath(), + parent->kit(), + copy.displayName)); - CMakeOpenProjectWizard::BuildInfo info; - info.sourceDirectory = project->projectDirectory(); - info.environment = Utils::Environment::systemEnvironment(); - parent->kit()->addToEnvironment(info.environment); - info.buildDirectory = project->shadowBuildDirectory(project->document()->fileName(), - parent->kit(), - buildConfigurationName); - info.kit = parent->kit(); - info.useNinja = false; // This is ignored anyway - - CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, info); + CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, ©); if (copw.exec() != QDialog::Accepted) return 0; CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(parent); - bc->setDisplayName(buildConfigurationName); + bc->setDisplayName(copy.displayName); + bc->setDefaultDisplayName(copy.displayName); ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); @@ -205,7 +196,7 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer: cleanMakeStep->setAdditionalArguments(QLatin1String("clean")); cleanMakeStep->setClean(true); - bc->setBuildDirectory(copw.buildDirectory()); + bc->setBuildDirectory(Utils::FileName::fromString(copw.buildDirectory())); bc->setUseNinja(copw.useNinja()); // Default to all @@ -217,7 +208,9 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer: bool CMakeBuildConfigurationFactory::canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const { - return canCreate(parent, source->id()); + if (!canHandle(parent)) + return false; + return source->id() == Constants::CMAKE_BC_ID; } CMakeBuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) @@ -230,7 +223,9 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer:: bool CMakeBuildConfigurationFactory::canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const { - return canCreate(parent, ProjectExplorer::idFromMap(map)); + if (!canHandle(parent)) + return false; + return ProjectExplorer::idFromMap(map) == Constants::CMAKE_BC_ID; } CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map) @@ -246,15 +241,31 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer bool CMakeBuildConfigurationFactory::canHandle(const ProjectExplorer::Target *t) const { + QTC_ASSERT(t, return false); if (!t->project()->supportsKit(t->kit())) return false; return qobject_cast<CMakeProject *>(t->project()); } +CMakeBuildInfo *CMakeBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k, + const QString &sourceDir) const +{ + CMakeBuildInfo *info = new CMakeBuildInfo(this); + info->typeName = tr("Build"); + info->kitId = k->id(); + info->environment = Utils::Environment::systemEnvironment(); + k->addToEnvironment(info->environment); + info->useNinja = false; + info->sourceDirectory = sourceDir; + info->supportsShadowBuild = true; + + return info; +} + ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const { QString cmakeBuildType; - QFile cmakeCache(buildDirectory() + QLatin1String("/CMakeCache.txt")); + QFile cmakeCache(buildDirectory().toString() + QLatin1String("/CMakeCache.txt")); if (cmakeCache.open(QIODevice::ReadOnly)) { while (!cmakeCache.atEnd()) { QByteArray line = cmakeCache.readLine(); diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h index 494c28ea2c..de7ab612d3 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h @@ -38,7 +38,10 @@ class ToolChain; } namespace CMakeProjectManager { +class CMakeBuildInfo; + namespace Internal { +class CMakeProject; class CMakeBuildConfigurationFactory; @@ -52,9 +55,6 @@ public: ~CMakeBuildConfiguration(); ProjectExplorer::NamedWidget *createConfigWidget(); - QString buildDirectory() const; - - void setBuildDirectory(const QString &buildDirectory); QVariantMap toMap() const; @@ -71,9 +71,10 @@ protected: bool fromMap(const QVariantMap &map); private: - QString m_buildDirectory; QString m_msvcVersion; bool m_useNinja; + + friend class CMakeProject; }; class CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory @@ -84,11 +85,14 @@ public: CMakeBuildConfigurationFactory(QObject *parent = 0); ~CMakeBuildConfigurationFactory(); - QList<Core::Id> availableCreationIds(const ProjectExplorer::Target *parent) const; - QString displayNameForId(const Core::Id id) const; + bool canCreate(const ProjectExplorer::Target *parent) const; + QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const; + bool canSetup(const ProjectExplorer::Kit *k, const QString &projectPath) const; + QList<ProjectExplorer::BuildInfo *> availableSetups(const ProjectExplorer::Kit *k, + const QString &projectPath) const; + ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent, + const ProjectExplorer::BuildInfo *info) const; - bool canCreate(const ProjectExplorer::Target *parent, const Core::Id id) const; - CMakeBuildConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name = QString()); bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const; CMakeBuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source); bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const; @@ -96,6 +100,7 @@ public: private: bool canHandle(const ProjectExplorer::Target *t) const; + CMakeBuildInfo *createBuildInfo(const ProjectExplorer::Kit *k, const QString &sourceDir) const; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp b/src/plugins/cmakeprojectmanager/cmakebuildinfo.h index f490b2554c..b352f95de9 100644 --- a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildinfo.h @@ -27,37 +27,39 @@ ** ****************************************************************************/ -#include "cmakeuicodemodelsupport.h" -#include "cmakeproject.h" +#ifndef CMAKEBUILDINFO_H +#define CMAKEBUILDINFO_H + #include "cmakebuildconfiguration.h" -#include <cpptools/cppmodelmanagerinterface.h> +#include <projectexplorer/buildinfo.h> +#include <projectexplorer/kit.h> #include <projectexplorer/target.h> +#include <utils/environment.h> -#include <QProcess> +namespace CMakeProjectManager { -using namespace CMakeProjectManager; -using namespace Internal; +class CMakeBuildInfo : public ProjectExplorer::BuildInfo +{ +public: + CMakeBuildInfo(const ProjectExplorer::IBuildConfigurationFactory *f) : + ProjectExplorer::BuildInfo(f) { } -CMakeUiCodeModelSupport::CMakeUiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager, - CMakeProject *project, - const QString &source, - const QString &uiHeaderFile) - : CppTools::UiCodeModelSupport(modelmanager, source, uiHeaderFile), - m_project(project) -{ } + CMakeBuildInfo(const Internal::CMakeBuildConfiguration *bc) : + ProjectExplorer::BuildInfo(ProjectExplorer::IBuildConfigurationFactory::find(bc->target())) + { + displayName = bc->displayName(); + buildDirectory = bc->buildDirectory(); + kitId = bc->target()->kit()->id(); + environment = bc->environment(); + useNinja = bc->useNinja(); + } -CMakeUiCodeModelSupport::~CMakeUiCodeModelSupport() -{ } + Utils::Environment environment; + QString sourceDirectory; + bool useNinja; +}; -QString CMakeUiCodeModelSupport::uicCommand() const -{ - return m_project->uicCommand(); -} +} // namespace CMakeProjectManager -QStringList CMakeUiCodeModelSupport::environment() const -{ - if (!m_project || !m_project->activeTarget() || !m_project->activeTarget()->activeBuildConfiguration()) - return QStringList(); - return m_project->activeTarget()->activeBuildConfiguration()->environment().toStringList(); -} +#endif // CMAKEBUILDINFO_H diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index f91450d541..f21f256a06 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -29,6 +29,7 @@ #include "cmakeeditor.h" +#include "cmakefilecompletionassist.h" #include "cmakehighlighter.h" #include "cmakeeditorfactory.h" #include "cmakeprojectconstants.h" @@ -38,15 +39,16 @@ #include <coreplugin/infobar.h> #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <extensionsystem/pluginmanager.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/session.h> -#include <texteditor/fontsettings.h> #include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorconstants.h> #include <texteditor/texteditorsettings.h> #include <QFileInfo> #include <QSharedPointer> +#include <QTextBlock> using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; @@ -60,7 +62,7 @@ CMakeEditor::CMakeEditor(CMakeEditorWidget *editor) { setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR, TextEditor::Constants::C_TEXTEDITOR)); - connect(this, SIGNAL(changed()), this, SLOT(markAsChanged())); + connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged())); } Core::IEditor *CMakeEditor::duplicate(QWidget *parent) @@ -68,7 +70,7 @@ Core::IEditor *CMakeEditor::duplicate(QWidget *parent) CMakeEditorWidget *w = qobject_cast<CMakeEditorWidget*>(widget()); CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory(), w->actionHandler()); ret->duplicateFrom(w); - TextEditor::TextEditorSettings::instance()->initializeEditor(ret); + TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); } @@ -77,6 +79,11 @@ Core::Id CMakeEditor::id() const return Core::Id(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); } +TextEditor::CompletionAssistProvider *CMakeEditor::completionAssistProvider() +{ + return ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>(); +} + void CMakeEditor::markAsChanged() { if (!document()->isModified()) @@ -94,12 +101,10 @@ void CMakeEditor::markAsChanged() void CMakeEditor::build() { - QList<ProjectExplorer::Project *> projects = - ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects(); - foreach (ProjectExplorer::Project *p, projects) { + foreach (ProjectExplorer::Project *p, ProjectExplorer::SessionManager::projects()) { CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p); if (cmakeProject) { - if (cmakeProject->isProjectFile(document()->fileName())) { + if (cmakeProject->isProjectFile(document()->filePath())) { ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject); break; } @@ -141,27 +146,6 @@ void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e) showDefaultContextMenu(e, Constants::M_CONTEXT); } -void CMakeEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) -{ - TextEditor::BaseTextEditorWidget::setFontSettings(fs); - CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter()); - if (!highlighter) - return; - - static QVector<TextEditor::TextStyle> categories; - if (categories.isEmpty()) { - categories << TextEditor::C_LABEL // variables - << TextEditor::C_KEYWORD // functions - << TextEditor::C_COMMENT - << TextEditor::C_STRING - << TextEditor::C_VISUAL_WHITESPACE; - } - - const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories); - highlighter->setFormats(formats.constBegin(), formats.constEnd()); - highlighter->rehighlight(); -} - static bool isValidFileNameChar(const QChar &c) { if (c.isLetterOrNumber() @@ -219,7 +203,7 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor, // TODO: Resolve variables - QDir dir(QFileInfo(editorDocument()->fileName()).absolutePath()); + QDir dir(QFileInfo(editorDocument()->filePath()).absolutePath()); QString fileName = dir.filePath(buffer); QFileInfo fi(fileName); if (fi.exists()) { @@ -250,12 +234,12 @@ CMakeDocument::CMakeDocument() QString CMakeDocument::defaultPath() const { - QFileInfo fi(fileName()); + QFileInfo fi(filePath()); return fi.absolutePath(); } QString CMakeDocument::suggestedFileName() const { - QFileInfo fi(fileName()); + QFileInfo fi(filePath()); return fi.fileName(); } diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h index 3a27b9b1cd..c35eebb26d 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h @@ -34,6 +34,7 @@ #include <texteditor/basetextdocument.h> #include <texteditor/basetexteditor.h> +#include <texteditor/codeassist/completionassistprovider.h> #include <utils/uncommentselection.h> @@ -58,7 +59,7 @@ public: bool duplicateSupported() const { return true; } Core::IEditor *duplicate(QWidget *parent); Core::Id id() const; - bool isTemporary() const { return false; } + TextEditor::CompletionAssistProvider *completionAssistProvider(); private slots: void markAsChanged(); @@ -86,7 +87,6 @@ protected: public slots: void unCommentSelection(); - void setFontSettings(const TextEditor::FontSettings &); private: CMakeEditorFactory *m_factory; diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp index 8bebdfaade..7b7b32ae5a 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp @@ -43,12 +43,15 @@ using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) - : m_mimeTypes(QStringList() << QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE)), - m_manager(manager) + : m_manager(manager) { using namespace Core; using namespace TextEditor; + setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); + setDisplayName(tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME)); + addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); + m_actionHandler = new TextEditorActionHandler(Constants::C_CMAKEEDITOR, TextEditorActionHandler::UnCommentSelection @@ -67,24 +70,9 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) contextMenu->addAction(cmd); } -Core::Id CMakeEditorFactory::id() const -{ - return Core::Id(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); -} - -QString CMakeEditorFactory::displayName() const -{ - return tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME); -} - Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent) { CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler); - TextEditor::TextEditorSettings::instance()->initializeEditor(rc); + TextEditor::TextEditorSettings::initializeEditor(rc); return rc->editor(); } - -QStringList CMakeEditorFactory::mimeTypes() const -{ - return m_mimeTypes; -} diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h index 279a99e10f..aafa5a4875 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h @@ -34,11 +34,7 @@ #include <coreplugin/editormanager/ieditorfactory.h> -#include <QStringList> - -namespace TextEditor { -class TextEditorActionHandler; -} +namespace TextEditor { class TextEditorActionHandler; } namespace CMakeProjectManager { namespace Internal { @@ -49,11 +45,6 @@ class CMakeEditorFactory : public Core::IEditorFactory public: CMakeEditorFactory(CMakeManager *parent); - - // IEditorFactory - QStringList mimeTypes() const; - Core::Id id() const; - QString displayName() const; Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h index 3f261d594a..5d0c3d76a1 100644 --- a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h +++ b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h @@ -39,6 +39,8 @@ class CMakeSettingsPage; class CMakeFileCompletionAssistProvider : public TextEditor::CompletionAssistProvider { + Q_OBJECT + public: CMakeFileCompletionAssistProvider(CMakeSettingsPage *settingsPage); ~CMakeFileCompletionAssistProvider(); diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp b/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp index 0a7c59ad96..8231f402f4 100644 --- a/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp @@ -30,9 +30,7 @@ #include "cmakehighlighter.h" #include <QRegExp> -#include <QColor> #include <QTextDocument> -#include <QTextEdit> using namespace CMakeProjectManager::Internal; @@ -48,6 +46,15 @@ static bool isVariable(const QByteArray &word) CMakeHighlighter::CMakeHighlighter(QTextDocument *document) : TextEditor::SyntaxHighlighter(document) { + static QVector<TextEditor::TextStyle> categories; + if (categories.isEmpty()) { + categories << TextEditor::C_LABEL // variables + << TextEditor::C_KEYWORD // functions + << TextEditor::C_COMMENT + << TextEditor::C_STRING + << TextEditor::C_VISUAL_WHITESPACE; + } + setTextFormatCategories(categories); } @@ -62,12 +69,12 @@ void CMakeHighlighter::highlightBlock(const QString &text) for (i=0; i < text.length(); i++) { char c = text.at(i).toLatin1(); if (inCommentMode) { - setFormat(i, 1, m_formats[CMakeCommentFormat]); + setFormat(i, 1, formatForCategory(CMakeCommentFormat)); } else { if (c == '#') { if (!inStringMode) { inCommentMode = true; - setFormat(i, 1, m_formats[CMakeCommentFormat]); + setFormat(i, 1, formatForCategory(CMakeCommentFormat)); buf.clear(); } else { buf += c; @@ -75,7 +82,7 @@ void CMakeHighlighter::highlightBlock(const QString &text) } else if (c == '(') { if (!inStringMode) { if (!buf.isEmpty()) - setFormat(i - buf.length(), buf.length(), m_formats[CMakeFunctionFormat]); + setFormat(i - buf.length(), buf.length(), formatForCategory(CMakeFunctionFormat)); buf.clear(); } else { buf += c; @@ -88,14 +95,13 @@ void CMakeHighlighter::highlightBlock(const QString &text) } else if (c == '\"') { buf += c; if (inStringMode) { - setFormat(i + 1 - buf.length(), buf.length(), m_formats[CMakeStringFormat]); + setFormat(i + 1 - buf.length(), buf.length(), formatForCategory(CMakeStringFormat)); buf.clear(); } else { - setFormat(i, 1, m_formats[CMakeStringFormat]); + setFormat(i, 1, formatForCategory(CMakeStringFormat)); } inStringMode = !inStringMode; - } - else if (c == '\\') { + } else if (c == '\\') { setFormat(i, 1, emptyFormat); buf += c; i++; @@ -106,14 +112,14 @@ void CMakeHighlighter::highlightBlock(const QString &text) } } else if (c == '$') { if (inStringMode) - setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]); + setFormat(i - buf.length(), buf.length(), formatForCategory(CMakeStringFormat)); buf.clear(); buf += c; setFormat(i, 1, emptyFormat); } else if (c == '}') { buf += c; if (isVariable(buf)) { - setFormat(i + 1 - buf.length(), buf.length(), m_formats[CMakeVariableFormat]); + setFormat(i + 1 - buf.length(), buf.length(), formatForCategory(CMakeVariableFormat)); buf.clear(); } } else { @@ -124,12 +130,12 @@ void CMakeHighlighter::highlightBlock(const QString &text) } if (inStringMode) { - setFormat(i - buf.length(), buf.length(), m_formats[CMakeStringFormat]); + setFormat(i - buf.length(), buf.length(), formatForCategory(CMakeStringFormat)); setCurrentBlockState(1); } else { setCurrentBlockState(0); } - applyFormatToSpaces(text, m_formats[CMakeVisualWhiteSpaceFormat]); + applyFormatToSpaces(text, formatForCategory(CMakeVisualWhiteSpaceFormat)); } diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighter.h b/src/plugins/cmakeprojectmanager/cmakehighlighter.h index ba6b31ac06..4cfef25a70 100644 --- a/src/plugins/cmakeprojectmanager/cmakehighlighter.h +++ b/src/plugins/cmakeprojectmanager/cmakehighlighter.h @@ -31,9 +31,6 @@ #define CMAKEHIGHLIGHTER_H #include <texteditor/syntaxhighlighter.h> -#include <QtAlgorithms> -#include <QSyntaxHighlighter> -#include <QTextCharFormat> namespace CMakeProjectManager { namespace Internal { @@ -50,21 +47,11 @@ public: CMakeFunctionFormat, CMakeCommentFormat, CMakeStringFormat, - CMakeVisualWhiteSpaceFormat, - NumCMakeFormats + CMakeVisualWhiteSpaceFormat }; CMakeHighlighter(QTextDocument *document = 0); virtual void highlightBlock(const QString &text); - - // Set formats from a sequence of type QTextCharFormat - template <class InputIterator> - void setFormats(InputIterator begin, InputIterator end) { - qCopy(begin, end, m_formats); - } - -private: - QTextCharFormat m_formats[NumCMakeFormats]; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.cpp b/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.cpp new file mode 100644 index 0000000000..1899afcf88 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** 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. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cmakehighlighterfactory.h" +#include "cmakeprojectconstants.h" +#include "cmakehighlighter.h" + +using namespace CMakeProjectManager::Internal; + +CMakeHighlighterFactory::CMakeHighlighterFactory() +{ + setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); + addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); +} + +TextEditor::SyntaxHighlighter *CMakeHighlighterFactory::createHighlighter() const +{ + return new CMakeHighlighter; +} diff --git a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h b/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.h index c68dafeed3..a6545022c6 100644 --- a/src/plugins/cmakeprojectmanager/cmakeuicodemodelsupport.h +++ b/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.h @@ -27,37 +27,25 @@ ** ****************************************************************************/ -#ifndef CMAKEUICODEMODELSUPPORT_H -#define CMAKEUICODEMODELSUPPORT_H +#ifndef CMAKEHIGHLIGHTERFACTORY_H +#define CMAKEHIGHLIGHTERFACTORY_H -#include <cpptools/uicodecompletionsupport.h> - -#include <QDateTime> - -namespace CppTools { class CppModelManagerInterface; } +#include <texteditor/ihighlighterfactory.h> namespace CMakeProjectManager { namespace Internal { -class CMakeProject; - -class CMakeUiCodeModelSupport : public CppTools::UiCodeModelSupport +class CMakeHighlighterFactory : public TextEditor::IHighlighterFactory { Q_OBJECT + public: - CMakeUiCodeModelSupport(CppTools::CppModelManagerInterface *modelmanager, - CMakeProject *project, - const QString &sourceFile, - const QString &uiHeaderFile); - ~CMakeUiCodeModelSupport(); -protected: - virtual QString uicCommand() const; - virtual QStringList environment() const; -private: - CMakeProject *m_project; + CMakeHighlighterFactory(); + + virtual TextEditor::SyntaxHighlighter *createHighlighter() const; }; +} // namespace Internal +} // namespace CMakeProjectManager -} // Internal -} // Qt4ProjectManager -#endif // CMAKEUICODEMODELSUPPORT_H +#endif // CMAKEHIGHLIGHTERFACTORY_H diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp index 401fc90a38..ab059a0639 100644 --- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp @@ -41,6 +41,7 @@ using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; +using namespace ProjectExplorer; using namespace Utils; CMakeLocatorFilter::CMakeLocatorFilter() @@ -49,10 +50,9 @@ CMakeLocatorFilter::CMakeLocatorFilter() setDisplayName(tr("Build CMake target")); setShortcutString(QLatin1String("cm")); - ProjectExplorer::SessionManager *sm = ProjectExplorer::ProjectExplorerPlugin::instance()->session(); - connect(sm, SIGNAL(projectAdded(ProjectExplorer::Project*)), + connect(SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(slotProjectListUpdated())); - connect(sm, SIGNAL(projectRemoved(ProjectExplorer::Project*)), + connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(slotProjectListUpdated())); // Initialize the filter @@ -69,16 +69,14 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca Q_UNUSED(future) QList<Locator::FilterEntry> result; - QList<ProjectExplorer::Project *> projects = - ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects(); - foreach (ProjectExplorer::Project *p, projects) { + foreach (Project *p, SessionManager::projects()) { CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p); if (cmakeProject) { foreach (const CMakeBuildTarget &ct, cmakeProject->buildTargets()) { if (ct.title.contains(entry)) { - Locator::FilterEntry entry(this, ct.title, cmakeProject->document()->fileName()); + Locator::FilterEntry entry(this, ct.title, cmakeProject->projectFilePath()); entry.extraInfo = FileUtils::shortNativePath( - FileName::fromString(cmakeProject->document()->fileName())); + FileName::fromString(cmakeProject->projectFilePath())); result.append(entry); } } @@ -93,11 +91,9 @@ void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const // Get the project containing the target selected CMakeProject *cmakeProject = 0; - QList<ProjectExplorer::Project *> projects = - ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects(); - foreach (ProjectExplorer::Project *p, projects) { + foreach (Project *p, SessionManager::projects()) { cmakeProject = qobject_cast<CMakeProject *>(p); - if (cmakeProject && cmakeProject->document()->fileName() == selection.internalData.toString()) + if (cmakeProject && cmakeProject->projectFilePath() == selection.internalData.toString()) break; cmakeProject = 0; } @@ -136,9 +132,7 @@ void CMakeLocatorFilter::slotProjectListUpdated() { CMakeProject *cmakeProject = 0; - QList<ProjectExplorer::Project *> projects = - ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects(); - foreach (ProjectExplorer::Project *p, projects) { + foreach (Project *p, SessionManager::projects()) { cmakeProject = qobject_cast<CMakeProject *>(p); if (cmakeProject) break; diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index ab3f402fa6..477a180224 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -30,6 +30,7 @@ #include "cmakeopenprojectwizard.h" #include "cmakeprojectmanager.h" #include "cmakebuildconfiguration.h" +#include "cmakebuildinfo.h" #include <coreplugin/icore.h> #include <utils/hostosinfo.h> @@ -42,6 +43,7 @@ #include <projectexplorer/abi.h> #include <projectexplorer/projectexplorerconstants.h> #include <texteditor/fontsettings.h> +#include <remotelinux/remotelinux_constants.h> #include <QVBoxLayout> #include <QFormLayout> @@ -179,7 +181,8 @@ QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, N if (!tc) return results; Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k); - if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) + if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE + && deviceType != RemoteLinux::Constants::GenericLinuxOsType) return results; ProjectExplorer::Abi targetAbi = tc->targetAbi(); if (n != ForceNinja) { @@ -238,13 +241,15 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const } CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, CMakeOpenProjectWizard::Mode mode, - const BuildInfo &info) + const CMakeBuildInfo *info) : m_cmakeManager(cmakeManager), - m_sourceDirectory(info.sourceDirectory), - m_environment(info.environment), - m_useNinja(info.useNinja), - m_kit(info.kit) + m_sourceDirectory(info->sourceDirectory), + m_environment(info->environment), + m_useNinja(info->useNinja), + m_kit(0) { + m_kit = ProjectExplorer::KitManager::find(info->kitId); + CMakeRunPage::Mode rmode; if (mode == CMakeOpenProjectWizard::NeedToCreate) rmode = CMakeRunPage::Recreate; @@ -256,13 +261,13 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, CMake rmode = CMakeRunPage::ChangeDirectory; if (mode == CMakeOpenProjectWizard::ChangeDirectory) { - m_buildDirectory = info.buildDirectory; + m_buildDirectory = info->buildDirectory.toString(); addPage(new ShadowBuildPage(this, true)); } if (!m_cmakeManager->isCMakeExecutableValid()) addPage(new ChooseCMakePage(this)); - addPage(new CMakeRunPage(this, rmode, info.buildDirectory)); + addPage(new CMakeRunPage(this, rmode, info->buildDirectory.toString())); init(); } @@ -292,8 +297,7 @@ bool CMakeOpenProjectWizard::compatibleKitExist() const bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator(); bool preferNinja = m_cmakeManager->preferNinja(); - QList<ProjectExplorer::Kit *> kitList = - ProjectExplorer::KitManager::instance()->kits(); + QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits(); foreach (ProjectExplorer::Kit *k, kitList) { // OfferNinja and ForceNinja differ in what they return @@ -617,7 +621,7 @@ QByteArray CMakeRunPage::cachedGeneratorFromFile(const QString &cache) void CMakeRunPage::initializePage() { if (m_mode == Initial) { - bool upToDateXmlFile = m_cmakeWizard->existsUpToDateXmlFile();; + bool upToDateXmlFile = m_cmakeWizard->existsUpToDateXmlFile(); m_buildDirectory = m_cmakeWizard->buildDirectory(); if (upToDateXmlFile) { @@ -665,8 +669,7 @@ void CMakeRunPage::initializePage() QByteArray cachedGenerator = cachedGeneratorFromFile(m_buildDirectory + QLatin1String("/CMakeCache.txt")); m_generatorComboBox->show(); - QList<ProjectExplorer::Kit *> kitList = - ProjectExplorer::KitManager::instance()->kits(); + QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits(); int defaultIndex = 0; foreach (ProjectExplorer::Kit *k, kitList) { @@ -675,7 +678,7 @@ void CMakeRunPage::initializePage() preferNinja, hasCodeBlocksGenerator); - if (k == ProjectExplorer::KitManager::instance()->defaultKit()) + if (k == ProjectExplorer::KitManager::defaultKit()) defaultIndex = m_generatorComboBox->count(); foreach (const GeneratorInfo &info, infos) diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h index 90db125212..793d635ab2 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h @@ -31,6 +31,7 @@ #define CMAKEOPENPROJECTWIZARD_H #include "cmakebuildconfiguration.h" +#include "cmakebuildinfo.h" #include <utils/environment.h> #include <utils/wizard.h> @@ -70,34 +71,13 @@ public: ChangeDirectory }; - class BuildInfo - { - public: - BuildInfo() - {} - - BuildInfo(CMakeBuildConfiguration *bc) - : sourceDirectory(bc->target()->project()->projectDirectory()) - , buildDirectory(bc->buildDirectory()) - , environment(bc->environment()) - , useNinja(bc->useNinja()) - , kit(bc->target()->kit()) - {} - - QString sourceDirectory; - QString buildDirectory; - Utils::Environment environment; - bool useNinja; - ProjectExplorer::Kit *kit; - }; - /// used at importing a project without a .user file CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, Utils::Environment env); /// used to update if we have already a .user file /// recreates or updates the cbp file /// Also used to change the build directory of one buildconfiguration or create a new buildconfiguration - CMakeOpenProjectWizard(CMakeManager *cmakeManager, Mode mode, const BuildInfo &info); + CMakeOpenProjectWizard(CMakeManager *cmakeManager, Mode mode, const CMakeBuildInfo *info); QString buildDirectory() const; QString sourceDirectory() const; diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.cpp b/src/plugins/cmakeprojectmanager/cmakeparser.cpp new file mode 100644 index 0000000000..631b445be7 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakeparser.cpp @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Axonian LLC. +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** 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. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cmakeparser.h" + +#include <utils/qtcassert.h> + +#include <projectexplorer/gnumakeparser.h> +#include <projectexplorer/projectexplorerconstants.h> + +using namespace CMakeProjectManager; +using namespace Internal; +using namespace ProjectExplorer; + +const char COMMON_ERROR_PATTERN[] = "^CMake Error at (.*):([0-9]*) \\((.*)\\):"; +const char NEXT_SUBERROR_PATTERN[] = "^CMake Error in (.*):"; + +CMakeParser::CMakeParser() : + m_skippedFirstEmptyLine(false) +{ + m_commonError.setPattern(QLatin1String(COMMON_ERROR_PATTERN)); + m_commonError.setMinimal(true); + QTC_CHECK(m_commonError.isValid()); + + m_nextSubError.setPattern(QLatin1String(NEXT_SUBERROR_PATTERN)); + m_nextSubError.setMinimal(true); + QTC_CHECK(m_nextSubError.isValid()); + appendOutputParser(new GnuMakeParser()); +} + +void CMakeParser::stdError(const QString &line) +{ + QString trimmedLine = rightTrimmed(line); + if (trimmedLine.isEmpty() && !m_lastTask.isNull()) { + if (m_skippedFirstEmptyLine) { + doFlush(); + } else { + m_skippedFirstEmptyLine = true; + } + return; + } + if (m_skippedFirstEmptyLine) + m_skippedFirstEmptyLine= false; + + if (m_commonError.indexIn(trimmedLine) != -1) { + m_lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(m_commonError.cap(1)), + m_commonError.cap(2).toInt(), Constants::TASK_CATEGORY_BUILDSYSTEM); + return; + } else if (m_nextSubError.indexIn(trimmedLine) != -1) { + m_lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(m_nextSubError.cap(1)), -1, + Constants::TASK_CATEGORY_BUILDSYSTEM); + return; + } else if (trimmedLine.startsWith(QLatin1String(" ")) && !m_lastTask.isNull()) { + if (!m_lastTask.description.isEmpty()) + m_lastTask.description.append(QLatin1Char(' ')); + m_lastTask.description.append(trimmedLine.trimmed()); + return; + } + + IOutputParser::stdError(line); +} + +void CMakeParser::doFlush() +{ + if (m_lastTask.isNull()) + return; + Task t = m_lastTask; + m_lastTask.clear(); + emit addTask(t); +} + +#ifdef WITH_TESTS +#include "cmakeprojectplugin.h" + +#include <projectexplorer/outputparser_test.h> + +#include <QTest> + +void CMakeProjectPlugin::testCMakeParser_data() +{ + QTest::addColumn<QString>("input"); + QTest::addColumn<OutputParserTester::Channel>("inputChannel"); + QTest::addColumn<QString>("childStdOutLines"); + QTest::addColumn<QString>("childStdErrLines"); + QTest::addColumn<QList<ProjectExplorer::Task> >("tasks"); + QTest::addColumn<QString>("outputLines"); + + const Core::Id categoryBuild = Constants::TASK_CATEGORY_BUILDSYSTEM; + + // negative tests + QTest::newRow("pass-through stdout") + << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT + << QString::fromLatin1("Sometext\n") << QString() + << QList<ProjectExplorer::Task>() + << QString(); + QTest::newRow("pass-through stderr") + << QString::fromLatin1("Sometext") << OutputParserTester::STDERR + << QString() << QString::fromLatin1("Sometext\n") + << QList<ProjectExplorer::Task>() + << QString(); + + // positive tests + QTest::newRow("add custom target") + << QString::fromLatin1("CMake Error at src/1/app/CMakeLists.txt:70 (add_custom_target):\n" + " Cannot find source file:\n\n" + " unknownFile.qml\n\n" + " Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp\n" + " .hxx .in .txx\n\n\n" + "CMake Error in src/1/app/CMakeLists.txt:\n" + " Cannot find source file:\n\n" + " CMakeLists.txt2\n\n" + " Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp\n" + " .hxx .in .txx\n\n") + << OutputParserTester::STDERR + << QString() << QString() + << (QList<ProjectExplorer::Task>() + << Task(Task::Error, + QLatin1String("Cannot find source file: unknownFile.qml Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx"), + Utils::FileName::fromUserInput(QLatin1String("src/1/app/CMakeLists.txt")), 70, + categoryBuild) + << Task(Task::Error, + QLatin1String("Cannot find source file: CMakeLists.txt2 Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx"), + Utils::FileName::fromUserInput(QLatin1String("src/1/app/CMakeLists.txt")), -1, + categoryBuild)) + << QString(); + + QTest::newRow("add subdirectory") + << QString::fromLatin1("CMake Error at src/1/CMakeLists.txt:8 (add_subdirectory):\n" + " add_subdirectory given source \"app1\" which is not an existing directory.\n\n") + << OutputParserTester::STDERR + << QString() << QString() + << (QList<ProjectExplorer::Task>() + << Task(Task::Error, + QLatin1String("add_subdirectory given source \"app1\" which is not an existing directory."), + Utils::FileName::fromUserInput(QLatin1String("src/1/CMakeLists.txt")), 8, + categoryBuild)) + << QString(); + + QTest::newRow("unknown command") + << QString::fromLatin1("CMake Error at src/1/CMakeLists.txt:8 (i_am_wrong_command):\n" + " Unknown CMake command \"i_am_wrong_command\".\n\n") + << OutputParserTester::STDERR + << QString() << QString() + << (QList<ProjectExplorer::Task>() + << Task(Task::Error, + QLatin1String("Unknown CMake command \"i_am_wrong_command\"."), + Utils::FileName::fromUserInput(QLatin1String("src/1/CMakeLists.txt")), 8, + categoryBuild)) + << QString(); + + QTest::newRow("incorrect arguments") + << QString::fromLatin1("CMake Error at src/1/CMakeLists.txt:8 (message):\n" + " message called with incorrect number of arguments\n\n") + << OutputParserTester::STDERR + << QString() << QString() + << (QList<ProjectExplorer::Task>() + << Task(Task::Error, + QLatin1String("message called with incorrect number of arguments"), + Utils::FileName::fromUserInput(QLatin1String("src/1/CMakeLists.txt")), 8, + categoryBuild)) + << QString(); +} + +void CMakeProjectPlugin::testCMakeParser() +{ + OutputParserTester testbench; + testbench.appendOutputParser(new CMakeParser); + QFETCH(QString, input); + QFETCH(OutputParserTester::Channel, inputChannel); + QFETCH(QList<Task>, tasks); + QFETCH(QString, childStdOutLines); + QFETCH(QString, childStdErrLines); + QFETCH(QString, outputLines); + + testbench.testParsing(input, inputChannel, + tasks, childStdOutLines, childStdErrLines, + outputLines); +} + +#endif diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.h b/src/plugins/cmakeprojectmanager/cmakeparser.h new file mode 100644 index 0000000000..24b61f9863 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakeparser.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Axonian LLC. +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** 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. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef CMAKEOUTPUTPARSER_H +#define CMAKEOUTPUTPARSER_H + +#include <projectexplorer/ioutputparser.h> +#include <projectexplorer/task.h> + +namespace CMakeProjectManager { +namespace Internal { + +class CMakeParser : public ProjectExplorer::IOutputParser +{ + Q_OBJECT + +public: + explicit CMakeParser(); + void stdError(const QString &line); + +protected: + void doFlush(); + +private: + ProjectExplorer::Task m_lastTask; + QRegExp m_commonError; + QRegExp m_nextSubError; + bool m_skippedFirstEmptyLine; +}; + +} // namespace CMakeProjectManager +} // namespace Internal + +#endif // CMAKEOUTPUTPARSER_H diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index bc6d5fc8a2..18fd8422e7 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -35,22 +35,24 @@ #include "cmakerunconfiguration.h" #include "makestep.h" #include "cmakeopenprojectwizard.h" -#include "cmakeuicodemodelsupport.h" #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/headerpath.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildmanager.h> +#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/kitinformation.h> #include <projectexplorer/kitmanager.h> #include <projectexplorer/toolchain.h> #include <projectexplorer/target.h> #include <projectexplorer/deployconfiguration.h> +#include <projectexplorer/deploymentdata.h> #include <projectexplorer/projectmacroexpander.h> #include <qtsupport/customexecutablerunconfiguration.h> #include <qtsupport/baseqtversion.h> #include <qtsupport/qtkitinformation.h> +#include <qtsupport/uicodemodelsupport.h> #include <cpptools/cppmodelmanagerinterface.h> #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> @@ -62,13 +64,9 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/variablemanager.h> -#include <QMap> #include <QDebug> #include <QDir> -#include <QDateTime> -#include <QProcess> #include <QFormLayout> -#include <QInputDialog> #include <QFileSystemWatcher> using namespace CMakeProjectManager; @@ -84,20 +82,6 @@ using namespace ProjectExplorer; // Open Questions // Who sets up the environment for cl.exe ? INCLUDEPATH and so on -// Test for form editor (loosely coupled) -static inline bool isFormWindowEditor(const QObject *o) -{ - return o && !qstrcmp(o->metaObject()->className(), "Designer::FormWindowEditor"); -} - -// Return contents of form editor (loosely coupled) -static inline QString formWindowEditorContents(const QObject *editor) -{ - const QVariant contentV = editor->property("contents"); - QTC_ASSERT(contentV.isValid(), return QString()); - return contentV.toString(); -} - /*! \class CMakeProject */ @@ -105,31 +89,24 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) : m_manager(manager), m_activeTarget(0), m_fileName(fileName), - m_rootNode(new CMakeProjectNode(m_fileName)), - m_lastEditor(0) + m_rootNode(new CMakeProjectNode(fileName)), + m_watcher(new QFileSystemWatcher(this)) { setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT)); setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); + m_projectName = QFileInfo(fileName).absoluteDir().dirName(); + m_file = new CMakeFile(this, fileName); connect(this, SIGNAL(buildTargetsChanged()), this, SLOT(updateRunConfigurations())); + + connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString))); } CMakeProject::~CMakeProject() { - // Remove CodeModel support - CppTools::CppModelManagerInterface *modelManager - = CppTools::CppModelManagerInterface::instance(); - QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end; - it = m_uiCodeModelSupport.constBegin(); - end = m_uiCodeModelSupport.constEnd(); - for (; it!=end; ++it) { - modelManager->removeEditorSupport(it.value()); - delete it.value(); - } - m_codeModelFuture.cancel(); delete m_rootNode; } @@ -149,7 +126,7 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur CMakeBuildConfiguration *cmakebc = static_cast<CMakeBuildConfiguration *>(bc); // Pop up a dialog asking the user to rerun cmake - QString cbpFile = CMakeManager::findCbpFile(QDir(bc->buildDirectory())); + QString cbpFile = CMakeManager::findCbpFile(QDir(bc->buildDirectory().toString())); QFileInfo cbpFileFi(cbpFile); CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing; if (!cbpFileFi.exists()) { @@ -164,8 +141,8 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur } if (mode != CMakeOpenProjectWizard::Nothing) { - CMakeOpenProjectWizard copw(m_manager, mode, - CMakeOpenProjectWizard::BuildInfo(cmakebc)); + CMakeBuildInfo info(cmakebc); + CMakeOpenProjectWizard copw(m_manager, mode, &info); if (copw.exec() == QDialog::Accepted) cmakebc->setUseNinja(copw.useNinja()); // NeedToCreate can change the Ninja setting } @@ -194,7 +171,7 @@ void CMakeProject::activeTargetWasChanged(Target *target) void CMakeProject::changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory) { - bc->setBuildDirectory(newBuildDirectory); + bc->setBuildDirectory(Utils::FileName::fromString(newBuildDirectory)); parseCMakeLists(); } @@ -219,12 +196,12 @@ bool CMakeProject::parseCMakeLists() } CMakeBuildConfiguration *activeBC = static_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration()); - foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors()) - if (isProjectFile(editor->document()->fileName())) - editor->document()->infoBar()->removeInfo(Core::Id("CMakeEditor.RunCMake")); + foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) + if (isProjectFile(document->filePath())) + document->infoBar()->removeInfo("CMakeEditor.RunCMake"); // Find cbp file - QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory()); + QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory().toString()); if (cbpFile.isEmpty()) { emit buildTargetsChanged(); @@ -286,20 +263,7 @@ bool CMakeProject::parseCMakeLists() // qDebug()<<""; // } - - // TOOD this code ain't very pretty ... - m_uicCommand.clear(); - QFile cmakeCache(activeBC->buildDirectory() + QLatin1String("/CMakeCache.txt")); - cmakeCache.open(QIODevice::ReadOnly); - while (!cmakeCache.atEnd()) { - QByteArray line = cmakeCache.readLine(); - if (line.startsWith("QT_UIC_EXECUTABLE")) { - if (int pos = line.indexOf('=')) - m_uicCommand = QString::fromLocal8Bit(line.mid(pos + 1).trimmed()); - break; - } - } - cmakeCache.close(); + updateApplicationAndDeploymentTargets(); createUiCodeModelSupport(); @@ -587,7 +551,7 @@ bool CMakeProject::fromMap(const QVariantMap &map) CMakeBuildConfiguration *bc(new CMakeBuildConfiguration(t)); bc->setDefaultDisplayName(QLatin1String("all")); bc->setUseNinja(copw.useNinja()); - bc->setBuildDirectory(copw.buildDirectory()); + bc->setBuildDirectory(Utils::FileName::fromString(copw.buildDirectory())); ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); @@ -601,9 +565,7 @@ bool CMakeProject::fromMap(const QVariantMap &map) t->addBuildConfiguration(bc); - DeployConfigurationFactory *fac = ExtensionSystem::PluginManager::instance()->getObject<DeployConfigurationFactory>(); - ProjectExplorer::DeployConfiguration *dc = fac->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID); - t->addDeployConfiguration(dc); + t->updateDefaultDeployConfigurations(); addTarget(t); } else { @@ -613,7 +575,7 @@ bool CMakeProject::fromMap(const QVariantMap &map) CMakeBuildConfiguration *activeBC = qobject_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration()); if (!activeBC) return false; - QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory())); + QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory().toString())); QFileInfo cbpFileFi(cbpFile); CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing; @@ -623,8 +585,8 @@ bool CMakeProject::fromMap(const QVariantMap &map) mode = CMakeOpenProjectWizard::NeedToUpdate; if (mode != CMakeOpenProjectWizard::Nothing) { - CMakeOpenProjectWizard copw(m_manager, mode, - CMakeOpenProjectWizard::BuildInfo(activeBC)); + CMakeBuildInfo info(activeBC); + CMakeOpenProjectWizard copw(m_manager, mode, &info); if (copw.exec() != QDialog::Accepted) return false; else @@ -632,27 +594,8 @@ bool CMakeProject::fromMap(const QVariantMap &map) } } - m_watcher = new QFileSystemWatcher(this); - connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString))); - parseCMakeLists(); - if (!hasUserFile && hasBuildTarget(QLatin1String("all"))) { - MakeStep *makeStep = qobject_cast<MakeStep *>( - activeTarget()->activeBuildConfiguration()->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD)->at(0)); - Q_ASSERT(makeStep); - makeStep->setBuildTarget(QLatin1String("all"), true); - } - - connect(Core::EditorManager::instance(), SIGNAL(editorAboutToClose(Core::IEditor*)), - this, SLOT(editorAboutToClose(Core::IEditor*))); - - connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), - this, SLOT(editorChanged(Core::IEditor*))); - - connect(ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)), - this, SLOT(buildStateChanged(ProjectExplorer::Project*))); - m_activeTarget = activeTarget(); if (m_activeTarget) connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), @@ -666,17 +609,9 @@ bool CMakeProject::fromMap(const QVariantMap &map) bool CMakeProject::setupTarget(Target *t) { - CMakeBuildConfigurationFactory *factory - = ExtensionSystem::PluginManager::instance()->getObject<CMakeBuildConfigurationFactory>(); - CMakeBuildConfiguration *bc = factory->create(t, Constants::CMAKE_BC_ID, QLatin1String("all")); - if (!bc) - return false; + t->updateDefaultBuildConfigurations(); + t->updateDefaultDeployConfigurations(); - t->addBuildConfiguration(bc); - - DeployConfigurationFactory *fac = ExtensionSystem::PluginManager::instance()->getObject<DeployConfigurationFactory>(); - ProjectExplorer::DeployConfiguration *dc = fac->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID); - t->addDeployConfiguration(dc); return true; } @@ -688,11 +623,6 @@ CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title) return CMakeBuildTarget(); } -QString CMakeProject::uicCommand() const -{ - return m_uicCommand; -} - QString CMakeProject::uiHeaderFile(const QString &uiFile) { QFileInfo fi(uiFile); @@ -711,7 +641,7 @@ QString CMakeProject::uiHeaderFile(const QString &uiFile) QDir srcDirRoot = QDir(project.toString()); QString relativePath = srcDirRoot.relativeFilePath(baseDirectory.toString()); - QDir buildDir = QDir(activeTarget()->activeBuildConfiguration()->buildDirectory()); + QDir buildDir = QDir(activeTarget()->activeBuildConfiguration()->buildDirectory().toString()); QString uiHeaderFilePath = buildDir.absoluteFilePath(relativePath); uiHeaderFilePath += QLatin1String("/ui_"); uiHeaderFilePath += fi.completeBaseName(); @@ -783,119 +713,69 @@ void CMakeProject::updateRunConfigurations(Target *t) } } -void CMakeProject::createUiCodeModelSupport() +void CMakeProject::updateApplicationAndDeploymentTargets() { -// qDebug()<<"creatUiCodeModelSupport()"; - CppTools::CppModelManagerInterface *modelManager - = CppTools::CppModelManagerInterface::instance(); - - // First move all to - QMap<QString, CMakeUiCodeModelSupport *> oldCodeModelSupport; - oldCodeModelSupport = m_uiCodeModelSupport; - m_uiCodeModelSupport.clear(); + Target *t = activeTarget(); - // Find all ui files - foreach (const QString &uiFile, m_files) { - if (uiFile.endsWith(QLatin1String(".ui"))) { - // UI file, not convert to - QString uiHeaderFilePath = uiHeaderFile(uiFile); - QMap<QString, CMakeUiCodeModelSupport *>::iterator it - = oldCodeModelSupport.find(uiFile); - if (it != oldCodeModelSupport.end()) { - // qDebug()<<"updated old codemodelsupport"; - CMakeUiCodeModelSupport *cms = it.value(); - cms->setFileName(uiHeaderFilePath); - m_uiCodeModelSupport.insert(it.key(), cms); - oldCodeModelSupport.erase(it); - } else { - // qDebug()<<"adding new codemodelsupport"; - CMakeUiCodeModelSupport *cms = new CMakeUiCodeModelSupport(modelManager, this, uiFile, uiHeaderFilePath); - m_uiCodeModelSupport.insert(uiFile, cms); - modelManager->addEditorSupport(cms); - } - } - } + QFile deploymentFile; + QTextStream deploymentStream; + QString deploymentPrefix; + QDir sourceDir; - // Remove old - QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end; - end = oldCodeModelSupport.constEnd(); - for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) { - modelManager->removeEditorSupport(it.value()); - delete it.value(); + sourceDir.setPath(t->project()->projectDirectory()); + deploymentFile.setFileName(sourceDir.filePath(QLatin1String("QtCreatorDeployment.txt"))); + if (deploymentFile.open(QFile::ReadOnly | QFile::Text)) { + deploymentStream.setDevice(&deploymentFile); + deploymentPrefix = deploymentStream.readLine(); + if (!deploymentPrefix.endsWith(QLatin1Char('/'))) + deploymentPrefix.append(QLatin1Char('/')); } -} -void CMakeProject::updateCodeModelSupportFromEditor(const QString &uiFileName, - const QString &contents) -{ - const QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it = - m_uiCodeModelSupport.constFind(uiFileName); - if (it != m_uiCodeModelSupport.constEnd()) - it.value()->updateFromEditor(contents); -} + BuildTargetInfoList appTargetList; + DeploymentData deploymentData; + QDir buildDir(t->activeBuildConfiguration()->buildDirectory().toString()); + foreach (const CMakeBuildTarget &ct, m_buildTargets) { + if (ct.executable.isEmpty()) + continue; -void CMakeProject::editorChanged(Core::IEditor *editor) -{ - // Handle old editor - if (isFormWindowEditor(m_lastEditor)) { - disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged())); - if (m_dirtyUic) { - const QString contents = formWindowEditorContents(m_lastEditor); - updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents); - m_dirtyUic = false; + deploymentData.addFile(ct.executable, deploymentPrefix + buildDir.relativeFilePath(QFileInfo(ct.executable).dir().path()), DeployableFile::TypeExecutable); + if (!ct.library) { + // TODO: Put a path to corresponding .cbp file into projectFilePath? + appTargetList.list << BuildTargetInfo(ct.executable, ct.executable); } } - m_lastEditor = editor; - - // Handle new editor - if (isFormWindowEditor(editor)) - connect(editor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged())); -} - -void CMakeProject::editorAboutToClose(Core::IEditor *editor) -{ - if (m_lastEditor == editor) { - // Oh no our editor is going to be closed - // get the content first - if (isFormWindowEditor(m_lastEditor)) { - disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged())); - if (m_dirtyUic) { - const QString contents = formWindowEditorContents(m_lastEditor); - updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents); - m_dirtyUic = false; - } - } - m_lastEditor = 0; + QString absoluteSourcePath = sourceDir.absolutePath(); + if (!absoluteSourcePath.endsWith(QLatin1Char('/'))) + absoluteSourcePath.append(QLatin1Char('/')); + while (!deploymentStream.atEnd()) { + QStringList file = deploymentStream.readLine().split(QLatin1Char(':')); + deploymentData.addFile(absoluteSourcePath + file.at(0), deploymentPrefix + file.at(1)); } -} -void CMakeProject::uiEditorContentsChanged() -{ - // cast sender, get filename - if (!m_dirtyUic && isFormWindowEditor(sender())) - m_dirtyUic = true; + t->setApplicationTargets(appTargetList); + t->setDeploymentData(deploymentData); } -void CMakeProject::buildStateChanged(ProjectExplorer::Project *project) +void CMakeProject::createUiCodeModelSupport() { - if (project == this) { - if (!ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager()->isBuilding(this)) { - QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end; - end = m_uiCodeModelSupport.constEnd(); - for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) { - it.value()->updateFromBuild(); - } - } + QHash<QString, QString> uiFileHash; + + // Find all ui files + foreach (const QString &uiFile, m_files) { + if (uiFile.endsWith(QLatin1String(".ui"))) + uiFileHash.insert(uiFile, uiHeaderFile(uiFile)); } + + QtSupport::UiCodeModelManager::update(this, uiFileHash); } // CMakeFile CMakeFile::CMakeFile(CMakeProject *parent, QString fileName) - : Core::IDocument(parent), m_project(parent), m_fileName(fileName) + : Core::IDocument(parent), m_project(parent) { - + setFilePath(fileName); } bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave) @@ -908,11 +788,6 @@ bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSav return false; } -QString CMakeFile::fileName() const -{ - return m_fileName; -} - QString CMakeFile::defaultPath() const { return QString(); @@ -939,13 +814,6 @@ bool CMakeFile::isSaveAsAllowed() const return false; } -void CMakeFile::rename(const QString &newName) -{ - Q_ASSERT(false); - Q_UNUSED(newName); - // Can't happen.... -} - Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) @@ -987,8 +855,8 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) fl->addRow(tr("Build directory:"), hbox); m_buildConfiguration = bc; - m_pathLineEdit->setText(m_buildConfiguration->buildDirectory()); - if (m_buildConfiguration->buildDirectory() == bc->target()->project()->projectDirectory()) + m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString()); + if (m_buildConfiguration->buildDirectory().toString() == bc->target()->project()->projectDirectory()) m_changeButton->setEnabled(false); else m_changeButton->setEnabled(true); @@ -999,12 +867,13 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog() { CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project()); + CMakeBuildInfo info(m_buildConfiguration); CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, - CMakeOpenProjectWizard::BuildInfo(m_buildConfiguration)); + &info); if (copw.exec() == QDialog::Accepted) { project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory()); m_buildConfiguration->setUseNinja(copw.useNinja()); - m_pathLineEdit->setText(m_buildConfiguration->buildDirectory()); + m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString()); } } @@ -1013,9 +882,9 @@ void CMakeBuildSettingsWidget::runCMake() if (!ProjectExplorer::ProjectExplorerPlugin::instance()->saveModifiedFiles()) return; CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project()); + CMakeBuildInfo info(m_buildConfiguration); CMakeOpenProjectWizard copw(project->projectManager(), - CMakeOpenProjectWizard::WantToUpdate, - CMakeOpenProjectWizard::BuildInfo(m_buildConfiguration)); + CMakeOpenProjectWizard::WantToUpdate, &info); if (copw.exec() == QDialog::Accepted) project->parseCMakeLists(); } @@ -1117,7 +986,7 @@ void CMakeCbpParser::parseBuildTargetOption() if (attributes().hasAttribute(QLatin1String("output"))) { m_buildTarget.executable = attributes().value(QLatin1String("output")).toString(); } else if (attributes().hasAttribute(QLatin1String("type"))) { - const QString value = attributes().value(QLatin1String("type")).toString(); + const QStringRef value = attributes().value(QLatin1String("type")); if (value == QLatin1String("2") || value == QLatin1String("3")) m_buildTarget.library = true; } else if (attributes().hasAttribute(QLatin1String("working_dir"))) { diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index f19422dcfc..c950575e0f 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -58,7 +58,6 @@ namespace Internal { class CMakeFile; class CMakeBuildSettingsWidget; -class CMakeUiCodeModelSupport; struct CMakeBuildTarget { @@ -94,10 +93,8 @@ public: CMakeBuildTarget buildTargetForTitle(const QString &title); - QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k, - const QString &bcName); - - QString uicCommand() const; + static QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k, + const QString &bcName); bool isProjectFile(const QString &fileName); @@ -119,27 +116,22 @@ private slots: void activeTargetWasChanged(ProjectExplorer::Target *target); void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*); - void editorChanged(Core::IEditor *editor); - void editorAboutToClose(Core::IEditor *editor); - void uiEditorContentsChanged(); - void buildStateChanged(ProjectExplorer::Project *project); void updateRunConfigurations(); private: void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list); void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list); ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory); - void updateCodeModelSupportFromEditor(const QString &uiFileName, const QString &contents); void createUiCodeModelSupport(); QString uiHeaderFile(const QString &uiFile); void updateRunConfigurations(ProjectExplorer::Target *t); + void updateApplicationAndDeploymentTargets(); CMakeManager *m_manager; ProjectExplorer::Target *m_activeTarget; QString m_fileName; CMakeFile *m_file; QString m_projectName; - QString m_uicCommand; // TODO probably need a CMake specific node structure CMakeProjectNode *m_rootNode; @@ -148,10 +140,6 @@ private: QFileSystemWatcher *m_watcher; QSet<QString> m_watchedFiles; QFuture<void> m_codeModelFuture; - - QMap<QString, CMakeUiCodeModelSupport *> m_uiCodeModelSupport; - Core::IEditor *m_lastEditor; - bool m_dirtyUic; }; class CMakeCbpParser : public QXmlStreamReader @@ -204,7 +192,6 @@ public: CMakeFile(CMakeProject *parent, QString fileName); bool save(QString *errorString, const QString &fileName, bool autoSave); - QString fileName() const; QString defaultPath() const; QString suggestedFileName() const; @@ -216,11 +203,8 @@ public: ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; bool reload(QString *errorString, ReloadFlag flag, ChangeType type); - void rename(const QString &newName); - private: CMakeProject *m_project; - QString m_fileName; }; class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h index 040070d15b..19042982e1 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h @@ -40,6 +40,7 @@ const char CMAKE_EDITOR_DISPLAY_NAME[] = "CMake Editor"; const char C_CMAKEEDITOR[] = "CMakeProject.Context.CMakeEditor"; const char RUNCMAKE[] = "CMakeProject.RunCMake"; const char RUNCMAKECONTEXTMENU[] = "CMakeProject.RunCMakeContextMenu"; +const char CMAKE_SUPPORT_FEATURE[] = "CMake.CMakeSupport"; // Project const char CMAKEPROJECT_ID[] = "CMakeProjectManager.CMakeProject"; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 910d027ab8..b480c9b5db 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -121,8 +121,9 @@ void CMakeManager::runCMake(ProjectExplorer::Project *project) CMakeBuildConfiguration *bc = static_cast<CMakeBuildConfiguration *>(cmakeProject->activeTarget()->activeBuildConfiguration()); - CMakeOpenProjectWizard copw(this, CMakeOpenProjectWizard::WantToUpdate, - CMakeOpenProjectWizard::BuildInfo(bc)); + CMakeBuildInfo info(bc); + + CMakeOpenProjectWizard copw(this, CMakeOpenProjectWizard::WantToUpdate, &info); if (copw.exec() == QDialog::Accepted) cmakeProject->parseCMakeLists(); } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index 5a79a0676e..e0e8c8ce97 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -1,6 +1,7 @@ include(../../qtcreatorplugin.pri) -HEADERS = cmakeproject.h \ +HEADERS = cmakebuildinfo.h \ + cmakeproject.h \ cmakeprojectplugin.h \ cmakeprojectmanager.h \ cmakeprojectconstants.h \ @@ -12,10 +13,11 @@ HEADERS = cmakeproject.h \ cmakeeditorfactory.h \ cmakeeditor.h \ cmakehighlighter.h \ - cmakeuicodemodelsupport.h \ + cmakehighlighterfactory.h \ cmakelocatorfilter.h \ cmakefilecompletionassist.h \ - cmakevalidator.h + cmakevalidator.h \ + cmakeparser.h SOURCES = cmakeproject.cpp \ cmakeprojectplugin.cpp \ @@ -28,9 +30,11 @@ SOURCES = cmakeproject.cpp \ cmakeeditorfactory.cpp \ cmakeeditor.cpp \ cmakehighlighter.cpp \ - cmakeuicodemodelsupport.cpp \ + cmakehighlighterfactory.cpp \ cmakelocatorfilter.cpp \ cmakefilecompletionassist.cpp \ - cmakevalidator.cpp + cmakevalidator.cpp \ + cmakeparser.cpp + RESOURCES += cmakeproject.qrc diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs index 1d8ca15973..1734c6cc94 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs @@ -22,6 +22,7 @@ QtcPlugin { "CMakeProjectManager.mimetypes.xml", "cmakebuildconfiguration.cpp", "cmakebuildconfiguration.h", + "cmakebuildinfo.h", "cmakeeditor.cpp", "cmakeeditor.h", "cmakeeditorfactory.cpp", @@ -30,10 +31,14 @@ QtcPlugin { "cmakefilecompletionassist.h", "cmakehighlighter.cpp", "cmakehighlighter.h", + "cmakehighlighterfactory.cpp", + "cmakehighlighterfactory.h", "cmakelocatorfilter.cpp", "cmakelocatorfilter.h", "cmakeopenprojectwizard.cpp", "cmakeopenprojectwizard.h", + "cmakeparser.cpp", + "cmakeparser.h", "cmakeproject.cpp", "cmakeproject.h", "cmakeproject.qrc", @@ -46,8 +51,6 @@ QtcPlugin { "cmakeprojectplugin.h", "cmakerunconfiguration.cpp", "cmakerunconfiguration.h", - "cmakeuicodemodelsupport.cpp", - "cmakeuicodemodelsupport.h", "cmakevalidator.cpp", "cmakevalidator.h", "makestep.cpp", diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp index 2d55f001e5..f4f35bd7e6 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp @@ -67,32 +67,28 @@ bool CMakeProjectNode::removeSubProjects(const QStringList &proFilePaths) return false; } -bool CMakeProjectNode::addFiles(const ProjectExplorer::FileType fileType, const QStringList &filePaths, QStringList *notAdded) +bool CMakeProjectNode::addFiles(const QStringList &filePaths, QStringList *notAdded) { - Q_UNUSED(fileType) Q_UNUSED(filePaths) Q_UNUSED(notAdded) return false; } -bool CMakeProjectNode::removeFiles(const ProjectExplorer::FileType fileType, const QStringList &filePaths, QStringList *notRemoved) +bool CMakeProjectNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved) { - Q_UNUSED(fileType) Q_UNUSED(filePaths) Q_UNUSED(notRemoved) return false; } -bool CMakeProjectNode::deleteFiles(const ProjectExplorer::FileType fileType, const QStringList &filePaths) +bool CMakeProjectNode::deleteFiles(const QStringList &filePaths) { - Q_UNUSED(fileType) Q_UNUSED(filePaths) return false; } -bool CMakeProjectNode::renameFile(const ProjectExplorer::FileType fileType, const QString &filePath, const QString &newFilePath) +bool CMakeProjectNode::renameFile(const QString &filePath, const QString &newFilePath) { - Q_UNUSED(fileType) Q_UNUSED(filePath) Q_UNUSED(newFilePath) return false; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h index 68738baca9..ef81cfae49 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h @@ -48,17 +48,13 @@ public: virtual bool addSubProjects(const QStringList &proFilePaths); virtual bool removeSubProjects(const QStringList &proFilePaths); - virtual bool addFiles(const ProjectExplorer::FileType fileType, - const QStringList &filePaths, + virtual bool addFiles( const QStringList &filePaths, QStringList *notAdded = 0); - virtual bool removeFiles(const ProjectExplorer::FileType fileType, - const QStringList &filePaths, + virtual bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0); - virtual bool deleteFiles(const ProjectExplorer::FileType fileType, - const QStringList &filePaths); - virtual bool renameFile(const ProjectExplorer::FileType fileType, - const QString &filePath, - const QString &newFilePath); + virtual bool deleteFiles(const QStringList &filePaths); + virtual bool renameFile(const QString &filePath, + const QString &newFilePath); virtual QList<ProjectExplorer::RunConfiguration *> runConfigurationsFor(Node *node); }; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 4022c4a99d..f72650ba4b 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -36,8 +36,9 @@ #include "cmakeprojectconstants.h" #include "cmakelocatorfilter.h" #include "cmakefilecompletionassist.h" +#include "cmakehighlighterfactory.h" -#include <coreplugin/icore.h> +#include <coreplugin/featureprovider.h> #include <coreplugin/mimedatabase.h> #include <texteditor/texteditoractionhandler.h> @@ -47,6 +48,16 @@ using namespace CMakeProjectManager::Internal; +class CMakeFeatureProvider : public Core::IFeatureProvider +{ + Core::FeatureSet availableFeatures(const QString & /* platform */) const { + return Core::FeatureSet(Core::Id(CMakeProjectManager::Constants::CMAKE_SUPPORT_FEATURE)); + } + + QStringList availablePlatforms() const { return QStringList(); } + QString displayNameForPlatform(const QString & /* platform */) const { return QString(); } +}; + CMakeProjectPlugin::CMakeProjectPlugin() { } @@ -57,7 +68,7 @@ CMakeProjectPlugin::~CMakeProjectPlugin() bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) { - if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml"), errorMessage)) + if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml"), errorMessage)) return false; CMakeSettingsPage *cmp = new CMakeSettingsPage(); addAutoReleasedObject(cmp); @@ -70,6 +81,8 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * addAutoReleasedObject(new CMakeEditorFactory(manager)); addAutoReleasedObject(new CMakeLocatorFilter); addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp)); + addAutoReleasedObject(new CMakeFeatureProvider); + addAutoReleasedObject(new CMakeHighlighterFactory); return true; } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h index 855ec1abd7..f7a0e17553 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h @@ -50,6 +50,12 @@ public: bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); + +private slots: +#ifdef WITH_TESTS + void testCMakeParser_data(); + void testCMakeParser(); +#endif }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 0d9fa3dcfc..e256fbe4f0 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -283,7 +283,7 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration * m_details->setLayout(fl); QVBoxLayout *vbx = new QVBoxLayout(this); - vbx->setMargin(0);; + vbx->setMargin(0); vbx->addWidget(m_detailsContainer); connect(m_workingDirectoryEdit, SIGNAL(changed(QString)), diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp index c6be30d700..5059965132 100644 --- a/src/plugins/cmakeprojectmanager/makestep.cpp +++ b/src/plugins/cmakeprojectmanager/makestep.cpp @@ -29,16 +29,16 @@ #include "makestep.h" +#include "cmakebuildconfiguration.h" +#include "cmakeparser.h" #include "cmakeprojectconstants.h" #include "cmakeproject.h" -#include "cmakebuildconfiguration.h" #include <projectexplorer/buildsteplist.h> #include <projectexplorer/deployconfiguration.h> -#include <projectexplorer/gnumakeparser.h> #include <projectexplorer/kitinformation.h> -#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/projectexplorer.h> #include <projectexplorer/target.h> #include <projectexplorer/toolchain.h> @@ -108,6 +108,9 @@ void MakeStep::ctor() this, SLOT(activeBuildConfigurationChanged())); activeBuildConfigurationChanged(); } + + connect(static_cast<CMakeProject *>(project()), SIGNAL(buildTargetsChanged()), + this, SLOT(buildTargetsChanged())); } MakeStep::~MakeStep() @@ -137,6 +140,16 @@ void MakeStep::activeBuildConfigurationChanged() } } +void MakeStep::buildTargetsChanged() +{ + QStringList filteredTargets; + foreach (const QString t, static_cast<CMakeProject *>(project())->buildTargetTitles()) { + if (m_buildTargets.contains(t)) + filteredTargets.append(t); + } + setBuildTargets(filteredTargets); +} + void MakeStep::setClean(bool clean) { m_clean = clean; @@ -174,7 +187,7 @@ bool MakeStep::init() if (!tc) { m_tasks.append(Task(Task::Error, tr("Qt Creator needs a compiler set up to build. Configure a compiler in the kit options."), Utils::FileName(), -1, - Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); return true; // otherwise the tasks will not get reported } @@ -192,12 +205,12 @@ bool MakeStep::init() if (m_useNinja && !env.value(QLatin1String("NINJA_STATUS")).startsWith(m_ninjaProgressString)) env.set(QLatin1String("NINJA_STATUS"), m_ninjaProgressString + QLatin1String("%o/sec] ")); pp->setEnvironment(env); - pp->setWorkingDirectory(bc->buildDirectory()); + pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setCommand(makeCommand(tc, bc->environment())); pp->setArguments(arguments); pp->resolveAll(); - setOutputParser(new ProjectExplorer::GnuMakeParser()); + setOutputParser(new CMakeParser()); IOutputParser *parser = target()->kit()->createOutputParser(); if (parser) appendOutputParser(parser); @@ -237,7 +250,7 @@ void MakeStep::stdOutput(const QString &line) { if (m_percentProgress.indexIn(line) != -1) { bool ok = false; - int percent = m_percentProgress.cap(1).toInt(&ok);; + int percent = m_percentProgress.cap(1).toInt(&ok); if (ok) futureInterface()->setProgressValue(percent); } else if (m_ninjaProgress.indexIn(line) != -1) { @@ -274,12 +287,15 @@ void MakeStep::setBuildTarget(const QString &buildTarget, bool on) old << buildTarget; else if (!on && old.contains(buildTarget)) old.removeOne(buildTarget); - m_buildTargets = old; + setBuildTargets(old); } void MakeStep::setBuildTargets(const QStringList &targets) { - m_buildTargets = targets; + if (targets != m_buildTargets) { + m_buildTargets = targets; + emit targetsToBuildChanged(); + } } void MakeStep::clearBuildTargets() @@ -336,7 +352,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) fl->addRow(tr("Targets:"), m_buildTargetsList); // TODO update this list also on rescans of the CMakeLists.txt - CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->target()->project()); + CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->project()); QStringList targetList = pro->buildTargetTitles(); targetList.sort(); foreach (const QString &buildTarget, targetList) { @@ -352,8 +368,8 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()), this, SLOT(updateDetails())); - connect(pro, SIGNAL(buildTargetsChanged()), - this, SLOT(buildTargetsChanged())); + connect(pro, SIGNAL(buildTargetsChanged()), this, SLOT(buildTargetsChanged())); + connect(m_makeStep, SIGNAL(targetsToBuildChanged()), this, SLOT(selectedBuildTargetsChanged())); connect(pro, SIGNAL(environmentChanged()), this, SLOT(updateDetails())); connect(m_makeStep, SIGNAL(makeCommandChanged()), this, SLOT(updateDetails())); } @@ -389,6 +405,17 @@ void MakeStepConfigWidget::buildTargetsChanged() updateSummary(); } +void MakeStepConfigWidget::selectedBuildTargetsChanged() +{ + disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); + for (int y = 0; y < m_buildTargetsList->count(); ++y) { + QListWidgetItem *item = m_buildTargetsList->itemAt(0, y); + item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked); + } + connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); + updateSummary(); +} + void MakeStepConfigWidget::updateDetails() { BuildConfiguration *bc = m_makeStep->buildConfiguration(); @@ -408,7 +435,7 @@ void MakeStepConfigWidget::updateDetails() ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); - param.setWorkingDirectory(bc->buildDirectory()); + param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(m_makeStep->makeCommand(tc, bc->environment())); param.setArguments(arguments); m_summaryText = param.summary(displayName()); diff --git a/src/plugins/cmakeprojectmanager/makestep.h b/src/plugins/cmakeprojectmanager/makestep.h index 9d3f972d39..1b03753c98 100644 --- a/src/plugins/cmakeprojectmanager/makestep.h +++ b/src/plugins/cmakeprojectmanager/makestep.h @@ -85,8 +85,12 @@ public slots: void setUseNinja(bool); void activeBuildConfigurationChanged(); +private slots: + void buildTargetsChanged(); + signals: void makeCommandChanged(); + void targetsToBuildChanged(); protected: void processStarted(); @@ -127,6 +131,8 @@ private slots: void additionalArgumentsEdited(); void updateDetails(); void buildTargetsChanged(); + void selectedBuildTargetsChanged(); + private: MakeStep *m_makeStep; QListWidget *m_buildTargetsList; |