2009-11-09 14:57:45 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-11-09 14:57:45 +01:00
|
|
|
**
|
|
|
|
|
** 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 "abldparser.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2009-11-11 11:00:54 +01:00
|
|
|
#include <projectexplorer/taskwindow.h>
|
2009-11-09 14:57:45 +01:00
|
|
|
|
2010-10-20 12:56:06 +02:00
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
|
2009-11-09 14:57:45 +01:00
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace ProjectExplorer;
|
2009-12-09 13:54:46 +01:00
|
|
|
using namespace ProjectExplorer::Constants;
|
2009-11-09 14:57:45 +01:00
|
|
|
|
2009-12-09 13:54:46 +01:00
|
|
|
AbldParser::AbldParser() :
|
2009-11-10 17:29:41 +01:00
|
|
|
m_currentLine(-1),
|
|
|
|
|
m_waitingForStdErrContinuation(false),
|
|
|
|
|
m_waitingForStdOutContinuation(false)
|
2009-11-09 14:57:45 +01:00
|
|
|
{
|
2010-08-11 14:49:21 +02:00
|
|
|
setObjectName(QLatin1String("AbldParser"));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_perlIssue.setPattern("^(WARNING|ERROR):\\s([^\\(\\)]+[^\\d])\\((\\d+)\\) : (.+)$");
|
|
|
|
|
m_perlIssue.setMinimal(true);
|
2009-11-09 14:57:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbldParser::stdOutput(const QString &line)
|
|
|
|
|
{
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdErrContinuation = false;
|
|
|
|
|
|
2009-11-09 14:57:45 +01:00
|
|
|
QString lne = line.trimmed();
|
|
|
|
|
// possible ABLD.bat errors:
|
2010-01-11 10:24:24 +01:00
|
|
|
if (lne.startsWith(QLatin1String("Is Perl, version "))) {
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
lne /* description */,
|
|
|
|
|
QString() /* filename */,
|
|
|
|
|
-1 /* linenumber */,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-09 14:57:45 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2010-07-07 16:42:41 +02:00
|
|
|
if (lne.startsWith(QLatin1String("FATAL ERROR:")) ||
|
|
|
|
|
lne.startsWith(QLatin1String("Error :"))) {
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
lne /* description */,
|
|
|
|
|
QString() /* filename */,
|
|
|
|
|
-1 /* linenumber */,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdOutContinuation = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_perlIssue.indexIn(lne) > -1) {
|
|
|
|
|
m_waitingForStdOutContinuation = true;
|
2010-10-20 12:56:06 +02:00
|
|
|
m_currentFile = QDir::fromNativeSeparators(m_perlIssue.cap(2));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_currentLine = m_perlIssue.cap(3).toInt();
|
|
|
|
|
|
2010-03-12 13:53:00 +01:00
|
|
|
Task task(Task::Unknown,
|
|
|
|
|
m_perlIssue.cap(4) /* description */,
|
|
|
|
|
m_currentFile, m_currentLine,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM);
|
2009-11-12 15:54:45 +01:00
|
|
|
|
|
|
|
|
if (m_perlIssue.cap(1) == QLatin1String("WARNING"))
|
2010-03-12 13:53:00 +01:00
|
|
|
task.type = Task::Warning;
|
2009-11-12 15:54:45 +01:00
|
|
|
else if (m_perlIssue.cap(1) == QLatin1String("ERROR"))
|
2010-03-12 13:53:00 +01:00
|
|
|
task.type = Task::Error;
|
2009-11-12 15:54:45 +01:00
|
|
|
|
2009-12-09 13:54:46 +01:00
|
|
|
emit addTask(task);
|
2009-11-10 17:29:41 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-07 16:42:41 +02:00
|
|
|
if (lne.startsWith(QLatin1String("SIS creation failed!"))) {
|
|
|
|
|
m_waitingForStdOutContinuation = false;
|
|
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
line, QString(), -1,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-10 17:29:41 +01:00
|
|
|
if (lne.isEmpty()) {
|
|
|
|
|
m_waitingForStdOutContinuation = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_waitingForStdOutContinuation) {
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Unknown,
|
|
|
|
|
lne /* description */,
|
|
|
|
|
m_currentFile, m_currentLine,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdOutContinuation = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-12-09 13:54:46 +01:00
|
|
|
IOutputParser::stdOutput(line);
|
2009-11-09 14:57:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbldParser::stdError(const QString &line)
|
|
|
|
|
{
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdOutContinuation = false;
|
|
|
|
|
|
2009-11-09 14:57:45 +01:00
|
|
|
QString lne = line.trimmed();
|
|
|
|
|
|
|
|
|
|
// possible abld.pl errors:
|
2010-01-11 10:24:24 +01:00
|
|
|
if (lne.startsWith(QLatin1String("ABLD ERROR:")) ||
|
|
|
|
|
lne.startsWith(QLatin1String("This project does not support ")) ||
|
|
|
|
|
lne.startsWith(QLatin1String("Platform "))) {
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
lne /* description */,
|
|
|
|
|
QString() /* filename */,
|
|
|
|
|
-1 /* linenumber */,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-09 14:57:45 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 10:24:24 +01:00
|
|
|
if (lne.startsWith(QLatin1String("Died at "))) {
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
lne /* description */,
|
|
|
|
|
QString() /* filename */,
|
|
|
|
|
-1 /* linenumber */,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdErrContinuation = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 10:24:24 +01:00
|
|
|
if (lne.startsWith(QLatin1String("MMPFILE \""))) {
|
2010-10-20 12:56:06 +02:00
|
|
|
m_currentFile = QDir::fromNativeSeparators(lne.mid(9, lne.size() - 10));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdErrContinuation = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (lne.isEmpty()) {
|
|
|
|
|
m_waitingForStdErrContinuation = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-01-11 10:24:24 +01:00
|
|
|
if (lne.startsWith(QLatin1String("WARNING: "))) {
|
2009-11-10 17:29:41 +01:00
|
|
|
QString description = lne.mid(9);
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Warning, description,
|
|
|
|
|
m_currentFile,
|
|
|
|
|
-1 /* linenumber */,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdErrContinuation = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-01-11 10:24:24 +01:00
|
|
|
if (lne.startsWith(QLatin1String("ERROR: "))) {
|
2009-11-10 17:29:41 +01:00
|
|
|
QString description = lne.mid(7);
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Error, description,
|
|
|
|
|
m_currentFile,
|
|
|
|
|
-1 /* linenumber */,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdErrContinuation = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (m_waitingForStdErrContinuation)
|
|
|
|
|
{
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Unknown,
|
|
|
|
|
lne /* description */,
|
|
|
|
|
m_currentFile,
|
|
|
|
|
-1 /* linenumber */,
|
|
|
|
|
TASK_CATEGORY_BUILDSYSTEM));
|
2009-11-10 17:29:41 +01:00
|
|
|
m_waitingForStdErrContinuation = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-12-09 13:54:46 +01:00
|
|
|
IOutputParser::stdError(line);
|
2009-11-09 14:57:45 +01:00
|
|
|
}
|
2010-03-29 17:59:58 +02:00
|
|
|
|
|
|
|
|
// Unit tests:
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
# include <QTest>
|
|
|
|
|
|
|
|
|
|
# include "qt4projectmanagerplugin.h"
|
|
|
|
|
|
|
|
|
|
# include "projectexplorer/outputparser_test.h"
|
|
|
|
|
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
|
|
|
|
void Qt4ProjectManagerPlugin::testAbldOutputParsers_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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTest::newRow("pass-through stdout")
|
|
|
|
|
<< QString::fromLatin1("Sometext") << OutputParserTester::STDOUT
|
|
|
|
|
<< QString::fromLatin1("Sometext") << QString()
|
|
|
|
|
<< QList<ProjectExplorer::Task>()
|
|
|
|
|
<< QString();
|
|
|
|
|
QTest::newRow("pass-through stderr")
|
|
|
|
|
<< QString::fromLatin1("Sometext") << OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString::fromLatin1("Sometext")
|
|
|
|
|
<< QList<ProjectExplorer::Task>()
|
|
|
|
|
<< QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4ProjectManagerPlugin::testAbldOutputParsers()
|
|
|
|
|
{
|
|
|
|
|
OutputParserTester testbench;
|
|
|
|
|
testbench.appendOutputParser(new AbldParser);
|
|
|
|
|
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
|