From d151493acca99cae5a1a583ca0f8b6d9d5d7e5b9 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <qt-info@nokia.com>
Date: Wed, 11 Nov 2009 17:06:58 +0100
Subject: [PATCH] Add buildparser for the QMake step

Add an option to have a buildparser for the qmake step and implement
a pretty simple parser.

Reviewed-By: dt
---
 .../projectexplorer/buildparserfactory.cpp    | 16 +++++
 .../projectexplorer/buildparserfactory.h      | 10 ++++
 .../projectexplorer/projectexplorer.cpp       |  1 +
 .../projectexplorer/projectexplorer.pro       |  7 ++-
 .../projectexplorerconstants.h                |  1 +
 src/plugins/projectexplorer/qmakeparser.cpp   | 58 +++++++++++++++++++
 src/plugins/projectexplorer/qmakeparser.h     | 53 +++++++++++++++++
 src/plugins/qt4projectmanager/qmakestep.cpp   |  6 +-
 src/plugins/qt4projectmanager/qmakestep.h     |  4 +-
 9 files changed, 150 insertions(+), 6 deletions(-)
 create mode 100644 src/plugins/projectexplorer/qmakeparser.cpp
 create mode 100644 src/plugins/projectexplorer/qmakeparser.h

diff --git a/src/plugins/projectexplorer/buildparserfactory.cpp b/src/plugins/projectexplorer/buildparserfactory.cpp
index e4b8895eaee..cb9326d68ba 100644
--- a/src/plugins/projectexplorer/buildparserfactory.cpp
+++ b/src/plugins/projectexplorer/buildparserfactory.cpp
@@ -32,6 +32,7 @@
 #include "projectexplorerconstants.h"
 #include "gccparser.h"
 #include "msvcparser.h"
+#include "qmakeparser.h"
 
 using namespace ProjectExplorer::Internal;
 
@@ -64,3 +65,18 @@ ProjectExplorer::IBuildParser * MsvcParserFactory::create(const QString & name)
     Q_UNUSED(name)
     return new MsvcParser();
 }
+
+QMakeParserFactory::~QMakeParserFactory()
+{
+}
+
+bool QMakeParserFactory::canCreate(const QString & name) const
+{
+    return (name == Constants::BUILD_PARSER_QMAKE);
+}
+
+ProjectExplorer::IBuildParser * QMakeParserFactory::create(const QString & name) const
+{
+    Q_UNUSED(name)
+    return new QMakeParser();
+}
diff --git a/src/plugins/projectexplorer/buildparserfactory.h b/src/plugins/projectexplorer/buildparserfactory.h
index e29570f2baf..f953d63ebf6 100644
--- a/src/plugins/projectexplorer/buildparserfactory.h
+++ b/src/plugins/projectexplorer/buildparserfactory.h
@@ -55,6 +55,16 @@ public:
     virtual ProjectExplorer::IBuildParser * create(const QString & name) const;
 };
 
+class QMakeParserFactory : public ProjectExplorer::IBuildParserFactory
+{
+    Q_OBJECT
+public:
+    QMakeParserFactory() {}
+    virtual ~QMakeParserFactory();
+    virtual bool canCreate(const QString & name) const;
+    virtual ProjectExplorer::IBuildParser * create(const QString & name) const;
+};
+
 } // namespace Internal
 } // namespace ProjectExplorer
 
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 9821118e87b..e0c5b18449b 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -308,6 +308,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
     // Build parsers
     addAutoReleasedObject(new GccParserFactory);
     addAutoReleasedObject(new MsvcParserFactory);
+    addAutoReleasedObject(new QMakeParserFactory);
 
     // Settings page
     addAutoReleasedObject(new ProjectExplorerSettingsPage);
diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro
index e0cf043e2bf..54a631e837d 100644
--- a/src/plugins/projectexplorer/projectexplorer.pro
+++ b/src/plugins/projectexplorer/projectexplorer.pro
@@ -65,7 +65,8 @@ HEADERS += projectexplorer.h \
     abstractmakestep.h \
     projectexplorersettingspage.h \
     projectwelcomepage.h \
-    projectwelcomepagewidget.h
+    projectwelcomepagewidget.h \
+    qmakeparser.h
 SOURCES += projectexplorer.cpp \
     projectwindow.cpp \
     buildmanager.cpp \
@@ -118,8 +119,8 @@ SOURCES += projectexplorer.cpp \
     projectexplorersettingspage.cpp \
     projectwelcomepage.cpp \
     projectwelcomepagewidget.cpp \
-    corelistenercheckingforrunningbuild.cpp
-
+    corelistenercheckingforrunningbuild.cpp \
+    qmakeparser.cpp
 FORMS += processstep.ui \
     editorsettingspropertiespage.ui \
     runsettingspropertiespage.ui \
diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h
index 5f01e404825..2e2b62be885 100644
--- a/src/plugins/projectexplorer/projectexplorerconstants.h
+++ b/src/plugins/projectexplorer/projectexplorerconstants.h
@@ -177,6 +177,7 @@ const char * const FORM_MIMETYPE = "application/x-designer";
 const char * const RESOURCE_MIMETYPE = "application/vnd.nokia.xml.qt.resource";
 
 // build parsers
+const char * const BUILD_PARSER_QMAKE       = "BuildParser.QMake";
 const char * const BUILD_PARSER_MSVC        = "BuildParser.MSVC";
 const char * const BUILD_PARSER_GCC         = "BuildParser.Gcc";
 const char * const BUILD_PARSER_RVCT        = "BuildParser.Rvct";
diff --git a/src/plugins/projectexplorer/qmakeparser.cpp b/src/plugins/projectexplorer/qmakeparser.cpp
new file mode 100644
index 00000000000..4350615a0c4
--- /dev/null
+++ b/src/plugins/projectexplorer/qmakeparser.cpp
@@ -0,0 +1,58 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "qmakeparser.h"
+#include "projectexplorerconstants.h"
+#include "taskwindow.h"
+
+using namespace ProjectExplorer;
+
+QMakeParser::QMakeParser()
+{
+}
+
+QString QMakeParser::name() const
+{
+    return QLatin1String(ProjectExplorer::Constants::BUILD_PARSER_QMAKE);
+}
+
+void QMakeParser::stdOutput(const QString & line)
+{
+}
+
+void QMakeParser::stdError(const QString & line)
+{
+    QString lne(line.trimmed());
+    if (lne.startsWith("Project ERROR:"))
+    {
+        lne = lne.mid(15);
+        emit addToTaskWindow(QString(), TaskWindow::Error, -1, lne);
+        return;
+    }
+}
diff --git a/src/plugins/projectexplorer/qmakeparser.h b/src/plugins/projectexplorer/qmakeparser.h
new file mode 100644
index 00000000000..5d5a1b02bb7
--- /dev/null
+++ b/src/plugins/projectexplorer/qmakeparser.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef QMAKEPARSER_H
+#define QMAKEPARSER_H
+
+#include "ibuildparser.h"
+
+#include <QtCore/QRegExp>
+
+namespace ProjectExplorer {
+
+class QMakeParser : public ProjectExplorer::IBuildParser
+{
+    Q_OBJECT
+
+public:
+    QMakeParser();
+    QString name() const;
+    virtual void stdOutput(const QString & line);
+    virtual void stdError(const QString & line);
+private:
+};
+
+} // namespace ProjectExplorer
+
+#endif // QMAKEPARSER_H
diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp
index ba8b57f75dd..2dd68e7edcb 100644
--- a/src/plugins/qt4projectmanager/qmakestep.cpp
+++ b/src/plugins/qt4projectmanager/qmakestep.cpp
@@ -38,6 +38,8 @@
 #include <coreplugin/icore.h>
 #include <utils/qtcassert.h>
 
+#include <projectexplorer/projectexplorerconstants.h>
+
 #include <QFileDialog>
 #include <QDir>
 #include <QFile>
@@ -48,7 +50,7 @@ using namespace Qt4ProjectManager::Internal;
 using namespace ProjectExplorer;
 
 QMakeStep::QMakeStep(Qt4Project *project)
-    : AbstractProcessStep(project), m_pro(project), m_forced(false)
+    : AbstractMakeStep(project), m_pro(project), m_forced(false)
 {
 }
 
@@ -137,6 +139,8 @@ bool QMakeStep::init(const QString &name)
     setCommand(name, program);
     setArguments(name, args);
     setEnvironment(name, m_pro->environment(bc));
+
+    setBuildParser(ProjectExplorer::Constants::BUILD_PARSER_QMAKE);
     return AbstractProcessStep::init(name);
 }
 
diff --git a/src/plugins/qt4projectmanager/qmakestep.h b/src/plugins/qt4projectmanager/qmakestep.h
index d23d471636e..f629c666388 100644
--- a/src/plugins/qt4projectmanager/qmakestep.h
+++ b/src/plugins/qt4projectmanager/qmakestep.h
@@ -32,7 +32,7 @@
 
 #include "ui_qmakestep.h"
 
-#include <projectexplorer/abstractprocessstep.h>
+#include <projectexplorer/abstractmakestep.h>
 
 #include <QStringList>
 
@@ -60,7 +60,7 @@ public:
 
 class Qt4Project;
 
-class QMakeStep : public ProjectExplorer::AbstractProcessStep
+class QMakeStep : public ProjectExplorer::AbstractMakeStep
 {
     Q_OBJECT
 
-- 
GitLab