diff --git a/src/plugins/projectexplorer/clangparser.h b/src/plugins/projectexplorer/clangparser.h index 5cda6e0764d..b15217f5628 100644 --- a/src/plugins/projectexplorer/clangparser.h +++ b/src/plugins/projectexplorer/clangparser.h @@ -37,7 +37,7 @@ namespace ProjectExplorer { -class ClangParser : public ProjectExplorer::GccParser +class PROJECTEXPLORER_EXPORT ClangParser : public ProjectExplorer::GccParser { Q_OBJECT diff --git a/src/plugins/projectexplorer/gccparser.h b/src/plugins/projectexplorer/gccparser.h index 015b53f0531..bd9609c3867 100644 --- a/src/plugins/projectexplorer/gccparser.h +++ b/src/plugins/projectexplorer/gccparser.h @@ -38,7 +38,7 @@ namespace ProjectExplorer { -class GccParser : public ProjectExplorer::IOutputParser +class PROJECTEXPLORER_EXPORT GccParser : public ProjectExplorer::IOutputParser { Q_OBJECT diff --git a/src/plugins/projectexplorer/msvcparser.h b/src/plugins/projectexplorer/msvcparser.h index e67547d53c9..a54c554c2aa 100644 --- a/src/plugins/projectexplorer/msvcparser.h +++ b/src/plugins/projectexplorer/msvcparser.h @@ -38,7 +38,7 @@ namespace ProjectExplorer { -class MsvcParser : public ProjectExplorer::IOutputParser +class PROJECTEXPLORER_EXPORT MsvcParser : public ProjectExplorer::IOutputParser { Q_OBJECT diff --git a/src/plugins/projectexplorer/osparser.h b/src/plugins/projectexplorer/osparser.h index ccc4364ca09..1ccbea39d8e 100644 --- a/src/plugins/projectexplorer/osparser.h +++ b/src/plugins/projectexplorer/osparser.h @@ -38,7 +38,7 @@ namespace ProjectExplorer { -class OsParser : public ProjectExplorer::IOutputParser +class PROJECTEXPLORER_EXPORT OsParser : public ProjectExplorer::IOutputParser { Q_OBJECT diff --git a/src/plugins/qt4projectmanager/qmakeparser.cpp b/src/plugins/qt4projectmanager/qmakeparser.cpp index d049d3d3f85..7c10fb60e12 100644 --- a/src/plugins/qt4projectmanager/qmakeparser.cpp +++ b/src/plugins/qt4projectmanager/qmakeparser.cpp @@ -33,7 +33,6 @@ #include using namespace QmakeProjectManager; -using namespace QmakeProjectManager::Internal; using ProjectExplorer::Task; QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+):(\\d+):\\s(.+)$")) diff --git a/src/plugins/qt4projectmanager/qmakeparser.h b/src/plugins/qt4projectmanager/qmakeparser.h index 68b73aa15e3..90a09db4a4f 100644 --- a/src/plugins/qt4projectmanager/qmakeparser.h +++ b/src/plugins/qt4projectmanager/qmakeparser.h @@ -30,14 +30,15 @@ #ifndef QMAKEPARSER_H #define QMAKEPARSER_H +#include "qmakeprojectmanager_global.h" + #include #include namespace QmakeProjectManager { -namespace Internal { -class QMakeParser : public ProjectExplorer::IOutputParser +class QT4PROJECTMANAGER_EXPORT QMakeParser : public ProjectExplorer::IOutputParser { Q_OBJECT @@ -49,7 +50,6 @@ private: QRegExp m_error; }; -} // namesapce Internal } // namespace QmakeProjectManager #endif // QMAKEPARSER_H diff --git a/src/tools/buildoutputparser/buildoutputparser.pro b/src/tools/buildoutputparser/buildoutputparser.pro new file mode 100644 index 00000000000..f02c37cc633 --- /dev/null +++ b/src/tools/buildoutputparser/buildoutputparser.pro @@ -0,0 +1,25 @@ +TEMPLATE = app +TARGET = buildoutputparser +QTC_LIB_DEPENDS = utils +QTC_PLUGIN_DEPENDS = projectexplorer qtsupport qt4projectmanager + +QT = core gui +CONFIG += console +CONFIG -= app_bundle + +include(../../../qtcreator.pri) +include(../../rpath.pri) + +LIBS += -L$$IDE_PLUGIN_PATH/QtProject +win32|equals(TEST, 1):DEFINES += HAS_MSVC_PARSER + +DESTDIR = $$IDE_BIN_PATH +target.path = /bin +INSTALLS += target + +SOURCES = \ + main.cpp \ + outputprocessor.cpp + +HEADERS = \ + outputprocessor.h diff --git a/src/tools/buildoutputparser/buildoutputparser.qbs b/src/tools/buildoutputparser/buildoutputparser.qbs new file mode 100644 index 00000000000..74651d8f664 --- /dev/null +++ b/src/tools/buildoutputparser/buildoutputparser.qbs @@ -0,0 +1,20 @@ +import qbs +import QtcTool + +QtcTool { + name: "buildoutputparser" + Depends { name: "Qt"; submodules: ["core", "widgets"]; } + Depends { name: "ProjectExplorer" } + Depends { name: "QtSupport" } + Depends { name: "Qt4ProjectManager" } + Depends { name: "Utils" } + files: [ + "main.cpp", + "outputprocessor.cpp", "outputprocessor.h", + ] + cpp.rpaths: base.concat(qbs.targetOS.contains("osx") + ? ["@executable_path/../"] + : ["$ORIGIN/../" + project.ide_plugin_path + "/QtProject"]) + cpp.defines: base.concat(qbs.targetOS.contains("windows") || project.testsEnabled + ? ["HAS_MSVC_PARSER"] : []) +} diff --git a/src/tools/buildoutputparser/main.cpp b/src/tools/buildoutputparser/main.cpp new file mode 100644 index 00000000000..2b72b519e26 --- /dev/null +++ b/src/tools/buildoutputparser/main.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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 "outputprocessor.h" + +#include +#include +#include +#include +#include + +#include +#include + +static void printUsage() +{ + fprintf(stderr, "Usage: %s [--type ] \n", + qPrintable(QFileInfo(QCoreApplication::applicationFilePath()).fileName())); + fprintf(stderr, "Possible compiler types: gcc, clang%s. Default is gcc.\n", +#ifdef HAS_MSVC_PARSER + ", msvc" +#else + "" +#endif + ); +} + + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + QStringList args = app.arguments().mid(1); + QString filePath; + CompilerType compilerType = CompilerTypeGcc; + while (filePath.isEmpty() && !args.isEmpty()) { + const QString currentArg = args.takeFirst(); + if (currentArg == QLatin1String("--type")) { + if (args.isEmpty()) { + fprintf(stderr, "Error: Option --type needs argument.\n"); + printUsage(); + return EXIT_FAILURE; + } + const QString typeString = args.takeFirst(); + if (typeString == QLatin1String("gcc")) { + compilerType = CompilerTypeGcc; + } else if (typeString == QLatin1String("clang")) { + compilerType = CompilerTypeClang; +#ifdef HAS_MSVC_PARSER + } else if (typeString == QLatin1String("msvc")) { + compilerType = CompilerTypeMsvc; +#endif + } else { + fprintf(stderr, "Invalid compiler type '%s'.\n", qPrintable(typeString)); + printUsage(); + return EXIT_FAILURE; + } + } else { + filePath = currentArg; + } + } + + if (filePath.isEmpty()) { + fprintf(stderr, "Error: No file supplied.\n"); + printUsage(); + return EXIT_FAILURE; + } + + if (!args.isEmpty()) + qDebug("Ignoring extraneous parameters '%s'.\n", qPrintable(args.join(QLatin1String(" ")))); + + QFile compilerOutputFile(filePath); + if (!compilerOutputFile.open(QIODevice::ReadOnly)) { + fprintf(stderr, "Error opening file '%s': %s\n", qPrintable(compilerOutputFile.fileName()), + qPrintable(compilerOutputFile.errorString())); + return EXIT_FAILURE; + } + CompilerOutputProcessor cop(compilerType, compilerOutputFile); + QMetaObject::invokeMethod(&cop, "start", Qt::QueuedConnection); + return app.exec(); +} diff --git a/src/tools/buildoutputparser/outputprocessor.cpp b/src/tools/buildoutputparser/outputprocessor.cpp new file mode 100644 index 00000000000..047638838c0 --- /dev/null +++ b/src/tools/buildoutputparser/outputprocessor.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 "outputprocessor.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAS_MSVC_PARSER +#include +#endif + +#include +#include + +#include + +CompilerOutputProcessor::CompilerOutputProcessor(CompilerType compilerType, QIODevice &source) + : m_compilerType(compilerType) + , m_source(source) + , m_ostream(new QTextStream(stdout, QIODevice::WriteOnly)) +{ +} + +CompilerOutputProcessor::~CompilerOutputProcessor() +{ + delete m_ostream; +} + +void CompilerOutputProcessor::start() +{ + ProjectExplorer::OsParser parser; + parser.appendOutputParser(new QmakeProjectManager::QMakeParser); + parser.appendOutputParser(new ProjectExplorer::GnuMakeParser); + parser.appendOutputParser(new QtSupport::QtParser); + switch (m_compilerType) { + case CompilerTypeGcc: + parser.appendOutputParser(new ProjectExplorer::GccParser); + break; + case CompilerTypeClang: + parser.appendOutputParser(new ProjectExplorer::ClangParser); + break; +#ifdef HAS_MSVC_PARSER + case CompilerTypeMsvc: + parser.appendOutputParser(new ProjectExplorer::MsvcParser); + break; +#endif + } + + connect(&parser, SIGNAL(addTask(ProjectExplorer::Task)), + SLOT(handleTask(ProjectExplorer::Task))); + while (!m_source.atEnd()) + parser.stdError(QString::fromLocal8Bit(m_source.readLine().trimmed())); + qApp->quit(); +} + +void CompilerOutputProcessor::handleTask(const ProjectExplorer::Task &task) +{ + const QString &fileName = task.file.toString(); + if (!fileName.isEmpty()) { + *m_ostream << fileName; + if (task.line != -1) + *m_ostream << ':' << task.line; + *m_ostream << ": "; + } + *m_ostream << task.description << endl; +} diff --git a/src/tools/buildoutputparser/outputprocessor.h b/src/tools/buildoutputparser/outputprocessor.h new file mode 100644 index 00000000000..a2eaf9cf1f0 --- /dev/null +++ b/src/tools/buildoutputparser/outputprocessor.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** 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 + +QT_BEGIN_NAMESPACE +class QIODevice; +class QTextStream; +QT_END_NAMESPACE + +namespace ProjectExplorer { class Task; } + +enum CompilerType { + CompilerTypeGcc, + CompilerTypeClang, +#ifdef HAS_MSVC_PARSER + CompilerTypeMsvc +#endif +}; + +class CompilerOutputProcessor : public QObject +{ + Q_OBJECT +public: + CompilerOutputProcessor(CompilerType compilerType, QIODevice &source); + ~CompilerOutputProcessor(); + +private slots: + void start(); + void handleTask(const ProjectExplorer::Task &task); + +private: + const CompilerType m_compilerType; + QIODevice &m_source; + QTextStream * const m_ostream; +}; diff --git a/src/tools/tools.pro b/src/tools/tools.pro index 6785bb782ab..de0e5d1be5a 100644 --- a/src/tools/tools.pro +++ b/src/tools/tools.pro @@ -5,7 +5,8 @@ SUBDIRS = qtpromaker \ ../plugins/cpaster/frontend \ sdktool \ valgrindfake \ - 3rdparty + 3rdparty \ + buildoutputparser win32 { SUBDIRS += qtcdebugger diff --git a/src/tools/tools.qbs b/src/tools/tools.qbs index 454ee9b77fe..38d2bcc20bc 100644 --- a/src/tools/tools.qbs +++ b/src/tools/tools.qbs @@ -3,6 +3,7 @@ import qbs Project { name: "Tools" references: [ + "buildoutputparser/buildoutputparser.qbs", "qtcdebugger/qtcdebugger.qbs", "qtcreatorcrashhandler/qtcreatorcrashhandler.qbs", "qtpromaker/qtpromaker.qbs",