2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-11-11 17:06:58 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-11-11 17:06:58 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-11-11 17:06:58 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2009-11-11 17:06:58 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-11-11 17:06:58 +01:00
|
|
|
|
|
|
|
|
#include "qmakeparser.h"
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2011-08-18 13:46:52 +02:00
|
|
|
#include <projectexplorer/task.h>
|
2009-11-30 19:16:00 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2011-01-24 12:29:48 +01:00
|
|
|
|
2009-11-30 19:16:00 +01:00
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
2010-03-12 13:53:00 +01:00
|
|
|
using ProjectExplorer::Task;
|
2009-11-30 19:16:00 +01:00
|
|
|
|
2011-08-18 13:46:52 +02:00
|
|
|
QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+):(\\d+):\\s(.+)$"))
|
2009-11-11 17:06:58 +01:00
|
|
|
{
|
2010-09-15 13:55:01 +02:00
|
|
|
setObjectName(QLatin1String("QMakeParser"));
|
2010-11-08 13:37:44 +01:00
|
|
|
m_error.setMinimal(true);
|
2009-11-11 17:06:58 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-09 13:54:46 +01:00
|
|
|
void QMakeParser::stdError(const QString &line)
|
2009-11-11 17:06:58 +01:00
|
|
|
{
|
2013-04-02 15:21:59 +02:00
|
|
|
QString lne = rightTrimmed(line);
|
2010-02-01 12:43:56 +01:00
|
|
|
if (lne.startsWith(QLatin1String("Project ERROR:"))) {
|
2009-12-09 13:54:46 +01:00
|
|
|
const QString description = lne.mid(15);
|
2010-03-12 13:53:00 +01:00
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
description,
|
2012-01-26 13:38:25 +01:00
|
|
|
Utils::FileName() /* filename */,
|
2010-03-12 13:53:00 +01:00
|
|
|
-1 /* linenumber */,
|
2012-01-26 13:38:25 +01:00
|
|
|
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
2009-11-11 17:06:58 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2010-11-08 13:37:44 +01:00
|
|
|
if (lne.startsWith(QLatin1String("Project WARNING:"))) {
|
|
|
|
|
const QString description = lne.mid(17);
|
|
|
|
|
emit addTask(Task(Task::Warning,
|
|
|
|
|
description,
|
2012-01-26 13:38:25 +01:00
|
|
|
Utils::FileName() /* filename */,
|
2010-11-08 13:37:44 +01:00
|
|
|
-1 /* linenumber */,
|
2012-01-26 13:38:25 +01:00
|
|
|
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
2010-11-08 13:37:44 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (m_error.indexIn(lne) > -1) {
|
2011-06-30 13:16:15 +02:00
|
|
|
QString fileName = m_error.cap(1);
|
2010-11-25 11:13:17 +01:00
|
|
|
Task::TaskType type = Task::Error;
|
2012-01-13 14:20:45 +01:00
|
|
|
if (fileName.startsWith(QLatin1String("WARNING: "))) {
|
2010-11-25 11:13:17 +01:00
|
|
|
type = Task::Warning;
|
|
|
|
|
fileName = fileName.mid(9);
|
2012-01-13 14:20:45 +01:00
|
|
|
} else if (fileName.startsWith(QLatin1String("ERROR: "))) {
|
2010-11-25 11:13:17 +01:00
|
|
|
fileName = fileName.mid(7);
|
|
|
|
|
}
|
|
|
|
|
emit addTask(Task(type,
|
2010-11-08 13:37:44 +01:00
|
|
|
m_error.cap(3) /* description */,
|
2012-01-26 13:38:25 +01:00
|
|
|
Utils::FileName::fromUserInput(fileName),
|
2010-11-08 13:37:44 +01:00
|
|
|
m_error.cap(2).toInt() /* line */,
|
2012-01-26 13:38:25 +01:00
|
|
|
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
2010-11-08 13:37:44 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2009-12-09 13:54:46 +01:00
|
|
|
IOutputParser::stdError(line);
|
2009-11-11 17:06:58 +01:00
|
|
|
}
|
2010-11-08 13:37:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Unit tests:
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
# include <QTest>
|
|
|
|
|
|
|
|
|
|
# include "qt4projectmanagerplugin.h"
|
|
|
|
|
|
|
|
|
|
# include "projectexplorer/outputparser_test.h"
|
|
|
|
|
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
void Qt4ProjectManagerPlugin::testQmakeOutputParsers_data()
|
|
|
|
|
{
|
2012-01-26 13:38:25 +01:00
|
|
|
const Core::Id categoryBuildSystem = Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
2010-11-08 13:37:44 +01:00
|
|
|
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
|
2011-05-18 18:39:14 +02:00
|
|
|
<< QString::fromLatin1("Sometext\n") << QString()
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QList<ProjectExplorer::Task>()
|
|
|
|
|
<< QString();
|
|
|
|
|
QTest::newRow("pass-through stderr")
|
|
|
|
|
<< QString::fromLatin1("Sometext") << OutputParserTester::STDERR
|
2011-05-18 18:39:14 +02:00
|
|
|
<< QString() << QString::fromLatin1("Sometext\n")
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QList<ProjectExplorer::Task>()
|
|
|
|
|
<< QString();
|
|
|
|
|
|
|
|
|
|
QTest::newRow("qMake error")
|
|
|
|
|
<< QString::fromLatin1("Project ERROR: undefined file")
|
|
|
|
|
<< OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString()
|
|
|
|
|
<< (QList<ProjectExplorer::Task>()
|
|
|
|
|
<< Task(Task::Error,
|
|
|
|
|
QLatin1String("undefined file"),
|
2012-01-26 13:38:25 +01:00
|
|
|
Utils::FileName(), -1,
|
2012-01-13 14:20:45 +01:00
|
|
|
categoryBuildSystem))
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QString();
|
|
|
|
|
|
|
|
|
|
QTest::newRow("qMake Parse Error")
|
|
|
|
|
<< QString::fromLatin1("e:\\project.pro:14: Parse Error ('sth odd')")
|
|
|
|
|
<< OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString()
|
|
|
|
|
<< (QList<ProjectExplorer::Task>()
|
|
|
|
|
<< Task(Task::Error,
|
|
|
|
|
QLatin1String("Parse Error ('sth odd')"),
|
2012-11-26 15:09:56 +02:00
|
|
|
Utils::FileName::fromUserInput(QLatin1String("e:\\project.pro")),
|
2010-11-08 13:37:44 +01:00
|
|
|
14,
|
2012-01-13 14:20:45 +01:00
|
|
|
categoryBuildSystem))
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QString();
|
|
|
|
|
|
|
|
|
|
QTest::newRow("qMake warning")
|
|
|
|
|
<< QString::fromLatin1("Project WARNING: bearer module might require ReadUserData capability")
|
|
|
|
|
<< OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString()
|
|
|
|
|
<< (QList<ProjectExplorer::Task>()
|
|
|
|
|
<< Task(Task::Warning,
|
|
|
|
|
QLatin1String("bearer module might require ReadUserData capability"),
|
2012-01-26 13:38:25 +01:00
|
|
|
Utils::FileName(), -1,
|
2012-01-13 14:20:45 +01:00
|
|
|
categoryBuildSystem))
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QString();
|
2010-11-25 11:13:17 +01:00
|
|
|
|
|
|
|
|
QTest::newRow("qMake warning with location")
|
2013-05-21 23:37:47 +03:00
|
|
|
<< QString::fromLatin1("WARNING: e:\\QtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl:1: Unescaped backslashes are deprecated.")
|
2010-11-25 11:13:17 +01:00
|
|
|
<< OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString()
|
|
|
|
|
<< (QList<ProjectExplorer::Task>()
|
|
|
|
|
<< Task(Task::Warning,
|
|
|
|
|
QLatin1String("Unescaped backslashes are deprecated."),
|
2013-05-21 23:37:47 +03:00
|
|
|
Utils::FileName::fromUserInput(QLatin1String("e:\\QtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl")), 1,
|
2012-01-13 14:20:45 +01:00
|
|
|
categoryBuildSystem))
|
2010-11-25 11:13:17 +01:00
|
|
|
<< QString();
|
2010-11-08 13:37:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4ProjectManagerPlugin::testQmakeOutputParsers()
|
|
|
|
|
{
|
|
|
|
|
OutputParserTester testbench;
|
|
|
|
|
testbench.appendOutputParser(new QMakeParser);
|
|
|
|
|
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
|