2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-11-11 17:06:58 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2009-11-11 17:06:58 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
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>
|
2015-04-20 17:13:45 +02:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2011-01-24 12:29:48 +01:00
|
|
|
|
2020-01-15 08:56:11 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace QmakeProjectManager {
|
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-11-08 13:37:44 +01:00
|
|
|
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;
|
2016-02-11 11:55:00 +01:00
|
|
|
const QString description = m_error.cap(3);
|
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);
|
|
|
|
|
}
|
2016-02-11 11:55:00 +01:00
|
|
|
if (description.startsWith(QLatin1String("note:"), Qt::CaseInsensitive))
|
|
|
|
|
type = Task::Unknown;
|
|
|
|
|
else if (description.startsWith(QLatin1String("warning:"), Qt::CaseInsensitive))
|
|
|
|
|
type = Task::Warning;
|
|
|
|
|
else if (description.startsWith(QLatin1String("error:"), Qt::CaseInsensitive))
|
|
|
|
|
type = Task::Error;
|
2020-01-15 08:56:11 +01:00
|
|
|
emit addTask(BuildSystemTask(type,
|
|
|
|
|
description,
|
|
|
|
|
FilePath::fromUserInput(fileName),
|
|
|
|
|
m_error.cap(2).toInt() /* line */),
|
|
|
|
|
1);
|
2010-11-08 13:37:44 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2015-07-03 12:06:27 +02:00
|
|
|
if (lne.startsWith(QLatin1String("Project ERROR: "))
|
|
|
|
|
|| lne.startsWith(QLatin1String("ERROR: "))) {
|
|
|
|
|
const QString description = lne.mid(lne.indexOf(QLatin1Char(':')) + 2);
|
2020-01-15 08:56:11 +01:00
|
|
|
emit addTask(BuildSystemTask(Task::Error, description), 1);
|
2015-07-03 12:06:27 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (lne.startsWith(QLatin1String("Project WARNING: "))
|
|
|
|
|
|| lne.startsWith(QLatin1String("WARNING: "))) {
|
|
|
|
|
const QString description = lne.mid(lne.indexOf(QLatin1Char(':')) + 2);
|
2020-01-15 08:56:11 +01:00
|
|
|
emit addTask(BuildSystemTask(Task::Warning, description), 1);
|
2015-07-03 12:06:27 +02: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
|
|
|
|
2020-01-15 08:56:11 +01:00
|
|
|
} // QmakeProjectManager
|
2010-11-08 13:37:44 +01:00
|
|
|
|
|
|
|
|
// Unit tests:
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
# include <QTest>
|
|
|
|
|
|
2013-10-16 12:10:22 +02:00
|
|
|
# include "qmakeprojectmanagerplugin.h"
|
2010-11-08 13:37:44 +01:00
|
|
|
|
|
|
|
|
# include "projectexplorer/outputparser_test.h"
|
|
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
using namespace QmakeProjectManager::Internal;
|
2020-01-15 08:56:11 +01:00
|
|
|
|
|
|
|
|
namespace QmakeProjectManager {
|
2010-11-08 13:37:44 +01:00
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::testQmakeOutputParsers_data()
|
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");
|
2019-05-27 16:09:44 +02:00
|
|
|
QTest::addColumn<Tasks >("tasks");
|
2010-11-08 13:37:44 +01:00
|
|
|
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()
|
2019-05-27 16:09:44 +02:00
|
|
|
<< Tasks()
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QString();
|
|
|
|
|
QTest::newRow("pass-through stderr")
|
|
|
|
|
<< QString::fromLatin1("Sometext") << OutputParserTester::STDERR
|
2011-05-18 18:39:14 +02:00
|
|
|
<< QString() << QString::fromLatin1("Sometext\n")
|
2019-05-27 16:09:44 +02:00
|
|
|
<< Tasks()
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QString();
|
|
|
|
|
|
|
|
|
|
QTest::newRow("qMake error")
|
|
|
|
|
<< QString::fromLatin1("Project ERROR: undefined file")
|
|
|
|
|
<< OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString()
|
2019-05-27 16:09:44 +02:00
|
|
|
<< (Tasks()
|
2020-01-15 08:56:11 +01:00
|
|
|
<< BuildSystemTask(Task::Error,
|
|
|
|
|
"undefined file"))
|
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()
|
2019-05-27 16:09:44 +02:00
|
|
|
<< (Tasks()
|
2020-01-15 08:56:11 +01:00
|
|
|
<< BuildSystemTask(Task::Error,
|
|
|
|
|
"Parse Error ('sth odd')",
|
|
|
|
|
FilePath::fromUserInput("e:\\project.pro"),
|
|
|
|
|
14))
|
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()
|
2019-05-27 16:09:44 +02:00
|
|
|
<< (Tasks()
|
2020-01-15 08:56:11 +01:00
|
|
|
<< BuildSystemTask(Task::Warning,
|
|
|
|
|
"bearer module might require ReadUserData capability"))
|
2010-11-08 13:37:44 +01:00
|
|
|
<< QString();
|
2010-11-25 11:13:17 +01:00
|
|
|
|
2015-07-03 12:06:27 +02:00
|
|
|
QTest::newRow("qMake warning 2")
|
|
|
|
|
<< QString::fromLatin1("WARNING: Failure to find: blackberrycreatepackagestepconfigwidget.cpp")
|
|
|
|
|
<< OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString()
|
2019-05-27 16:09:44 +02:00
|
|
|
<< (Tasks()
|
2020-01-15 08:56:11 +01:00
|
|
|
<< BuildSystemTask(Task::Warning,
|
|
|
|
|
"Failure to find: blackberrycreatepackagestepconfigwidget.cpp"))
|
2015-07-03 12:06:27 +02: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()
|
2019-05-27 16:09:44 +02:00
|
|
|
<< (Tasks()
|
2020-01-15 08:56:11 +01:00
|
|
|
<< BuildSystemTask(Task::Warning,
|
|
|
|
|
"Unescaped backslashes are deprecated.",
|
|
|
|
|
FilePath::fromUserInput("e:\\QtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl"), 1))
|
2010-11-25 11:13:17 +01:00
|
|
|
<< QString();
|
2020-01-15 08:56:11 +01:00
|
|
|
|
2016-02-11 11:55:00 +01:00
|
|
|
QTest::newRow("moc note")
|
|
|
|
|
<< QString::fromLatin1("/home/qtwebkithelpviewer.h:0: Note: No relevant classes found. No output generated.")
|
|
|
|
|
<< OutputParserTester::STDERR
|
|
|
|
|
<< QString() << QString()
|
2019-05-27 16:09:44 +02:00
|
|
|
<< (Tasks()
|
2020-01-15 08:56:11 +01:00
|
|
|
<< BuildSystemTask(Task::Unknown,
|
|
|
|
|
"Note: No relevant classes found. No output generated.",
|
|
|
|
|
FilePath::fromUserInput("/home/qtwebkithelpviewer.h"), 0))
|
|
|
|
|
<< QString();
|
|
|
|
|
}
|
2010-11-08 13:37:44 +01:00
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
void QmakeProjectManagerPlugin::testQmakeOutputParsers()
|
2010-11-08 13:37:44 +01:00
|
|
|
{
|
|
|
|
|
OutputParserTester testbench;
|
|
|
|
|
testbench.appendOutputParser(new QMakeParser);
|
|
|
|
|
QFETCH(QString, input);
|
|
|
|
|
QFETCH(OutputParserTester::Channel, inputChannel);
|
2019-05-27 16:09:44 +02:00
|
|
|
QFETCH(Tasks, tasks);
|
2010-11-08 13:37:44 +01:00
|
|
|
QFETCH(QString, childStdOutLines);
|
|
|
|
|
QFETCH(QString, childStdErrLines);
|
|
|
|
|
QFETCH(QString, outputLines);
|
|
|
|
|
|
|
|
|
|
testbench.testParsing(input, inputChannel,
|
|
|
|
|
tasks, childStdOutLines, childStdErrLines,
|
|
|
|
|
outputLines);
|
|
|
|
|
}
|
2020-01-15 08:56:11 +01:00
|
|
|
|
|
|
|
|
} // QmakeProjectManager
|
|
|
|
|
|
2010-11-08 13:37:44 +01:00
|
|
|
#endif
|