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

Improve SBSv2 parser

 * Report all commands that failed.
parent 7a5df3c3
No related branches found
No related tags found
No related merge requests found
...@@ -148,23 +148,50 @@ void SbsV2Parser::readWarning() ...@@ -148,23 +148,50 @@ void SbsV2Parser::readWarning()
void SbsV2Parser::readRecipe() void SbsV2Parser::readRecipe()
{ {
Q_ASSERT(m_log.isStartElement() && m_log.name() == QLatin1String("recipe")); Q_ASSERT(m_log.isStartElement() && m_log.name() == QLatin1String("recipe"));
const QString name = m_log.attributes().value(QLatin1String("name")).toString(); const QString name = m_log.attributes().value(QLatin1String("name")).toString();
m_currentSource = QDir(m_log.attributes().value("source").toString()).absolutePath();
m_currentTarget = QDir(m_log.attributes().value("target").toString()).absolutePath();
int returnCode = 0;
QString outputText;
QXmlStreamReader::TokenType tokenType = QXmlStreamReader::Invalid;
while ((tokenType = m_log.readNext()) != QXmlStreamReader::Invalid) {
if (tokenType == QXmlStreamReader::Characters) {
outputText.append(m_log.text());
} else if (tokenType == QXmlStreamReader::StartElement) {
if (m_log.name() == QLatin1String("status")) {
if (m_log.attributes().value(QLatin1String("exit")) == QLatin1String("failed"))
returnCode = m_log.attributes().value(QLatin1String("code")).toString().toInt();
}
} else if (tokenType == QXmlStreamReader::EndElement) {
if (m_log.name() == QLatin1String("recipe"))
break;
}
}
if (name == QLatin1String("compile") || QStringList output = outputText.split(QChar('\n'));
name == QLatin1String("qmake_extra_pre_targetdep")) { outputText.clear();
m_currentSource = QDir(m_log.attributes().value("source").toString()).absolutePath(); foreach (const QString &line, output) {
m_currentTarget = QDir(m_log.attributes().value("target").toString()).absolutePath(); if (line.isEmpty())
qDebug() << "SOURCE:" << m_currentSource.absolutePath(); continue;
qDebug() << "TARGET:" << m_currentTarget.absolutePath(); if (line.startsWith(QChar('+'))) {
outputText.append(tr("Running command: %1\n").arg(line.mid(2)));
QStringList output = m_log.readElementText().split(QChar('\n')); continue;
foreach (const QString &line, output) {
if (line.isEmpty() || line.startsWith(QChar('+')))
continue;
IOutputParser::stdError(line);
} }
} else { outputText.append(line);
m_log.skipCurrentElement(); outputText.append(QChar('\n'));
if (name == QLatin1String("compile") || name == QLatin1String("qmake_extra_pre_targetdep"))
IOutputParser::stdError(line);
}
if (returnCode != 0) {
//: %1 is the SBSv2 build recipe name, %2 the return code of the failed command
QString description = tr("Recipe %1 failed with exit code %2.").arg(name).arg(returnCode);
m_hub->addTask(Task(Task::Error, description, QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
m_hub->addTask(Task(Task::Unknown, outputText, QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }
......
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