Skip to content
Snippets Groups Projects
Commit 9ccd2f15 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Report errors in Makefiles in gnumakeparser

 * Report errors in Makefiles
 * Skip all but the first fatal error
parent 54393f7e
No related branches found
No related tags found
No related merge requests found
...@@ -41,13 +41,16 @@ namespace { ...@@ -41,13 +41,16 @@ namespace {
const char * const MAKE_PATTERN("^(mingw(32|64)-|g)?make(\\[\\d+\\])?:\\s"); const char * const MAKE_PATTERN("^(mingw(32|64)-|g)?make(\\[\\d+\\])?:\\s");
} }
GnuMakeParser::GnuMakeParser(const QString &dir) GnuMakeParser::GnuMakeParser(const QString &dir) :
m_alreadyFatal(false)
{ {
m_makeDir.setPattern(QLatin1String(MAKE_PATTERN) + m_makeDir.setPattern(QLatin1String(MAKE_PATTERN) +
QLatin1String("(\\w+) directory .(.+).$")); QLatin1String("(\\w+) directory .(.+).$"));
m_makeDir.setMinimal(true); m_makeDir.setMinimal(true);
m_makeLine.setPattern(QLatin1String(MAKE_PATTERN) + QLatin1String("(.*)$")); m_makeLine.setPattern(QLatin1String(MAKE_PATTERN) + QLatin1String("(.*)$"));
m_makeLine.setMinimal(true); m_makeLine.setMinimal(true);
m_makefileError.setPattern(QLatin1String("^(.*):(\\d+):\\s\\*\\*\\*\\s(.*)$"));
m_makefileError.setMinimal(true);
addDirectory(dir); addDirectory(dir);
} }
...@@ -62,18 +65,34 @@ void GnuMakeParser::stdOutput(const QString &line) ...@@ -62,18 +65,34 @@ void GnuMakeParser::stdOutput(const QString &line)
addDirectory(m_makeDir.cap(5)); addDirectory(m_makeDir.cap(5));
return; return;
} }
// Only ever report the first fatal message:
// Everything else will be follow-up issues.
if (m_makeLine.indexIn(lne) > -1) { if (m_makeLine.indexIn(lne) > -1) {
QString message = m_makeLine.cap(4); if (!m_alreadyFatal) {
Task task(Task::Warning, QString message = m_makeLine.cap(4);
message, Task task(Task::Warning,
QString() /* filename */, message,
-1, /* line */ QString() /* filename */,
Constants::TASK_CATEGORY_BUILDSYSTEM); -1, /* line */
if (message.startsWith(QLatin1String("*** "))) { Constants::TASK_CATEGORY_BUILDSYSTEM);
task.description = task.description.mid(4); if (message.startsWith(QLatin1String("*** "))) {
task.type = Task::Error; task.description = task.description.mid(4);
task.type = Task::Error;
m_alreadyFatal = true;
}
addTask(task);
}
return;
}
if (m_makefileError.indexIn(lne) > -1) {
if (!m_alreadyFatal) {
m_alreadyFatal = true;
addTask(Task(Task::Error,
m_makefileError.cap(3),
m_makefileError.cap(1),
m_makefileError.cap(2).toInt(),
Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
addTask(task);
return; return;
} }
...@@ -204,6 +223,32 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing_data() ...@@ -204,6 +223,32 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing_data()
Constants::TASK_CATEGORY_BUILDSYSTEM)) Constants::TASK_CATEGORY_BUILDSYSTEM))
<< QString() << QString()
<< QStringList(); << QStringList();
QTest::newRow("multiple fatals")
<< QStringList()
<< QString::fromLatin1("make[3]: *** [.obj/debug-shared/gnumakeparser.o] Error 1\n"
"make[3]: *** Waiting for unfinished jobs....\n"
"make[2]: *** [sub-projectexplorer-make_default] Error 2")
<< OutputParserTester::STDOUT
<< QString() << QString()
<< (QList<Task>()
<< Task(Task::Error,
QString::fromLatin1("[.obj/debug-shared/gnumakeparser.o] Error 1"),
QString(), -1,
Constants::TASK_CATEGORY_BUILDSYSTEM))
<< QString()
<< QStringList();
QTest::newRow("Makefile error")
<< QStringList()
<< QString::fromLatin1("Makefile:360: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.")
<< OutputParserTester::STDOUT
<< QString() << QString()
<< (QList<Task>()
<< Task(Task::Error,
QString::fromLatin1("missing separator (did you mean TAB instead of 8 spaces?). Stop."),
QString::fromLatin1("Makefile"), 360,
Constants::TASK_CATEGORY_BUILDSYSTEM))
<< QString()
<< QStringList();
} }
void ProjectExplorerPlugin::testGnuMakeParserParsing() void ProjectExplorerPlugin::testGnuMakeParserParsing()
......
...@@ -57,12 +57,14 @@ private: ...@@ -57,12 +57,14 @@ private:
QRegExp m_makeDir; QRegExp m_makeDir;
QRegExp m_makeLine; QRegExp m_makeLine;
QRegExp m_makefileError;
QStringList m_directories; QStringList m_directories;
#if defined WITH_TESTS #if defined WITH_TESTS
friend class ProjectExplorerPlugin; friend class ProjectExplorerPlugin;
#endif #endif
bool m_alreadyFatal;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment