diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-05-26 14:34:52 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-05-26 13:11:01 +0000 |
commit | 301a388982b9a6ce809e507fe660966846e05649 (patch) | |
tree | 96b46baa3d8e693521a360a244d18b1da9921cdc | |
parent | 9c3d4dcc8853edb33e1794f78500dfc9c2ea53de (diff) | |
download | qt-creator-301a388982b9a6ce809e507fe660966846e05649.tar.gz |
CMake: Split build output into lines before parsing
This amends commit b15d1951a2, where we moved the line splitting into
the output parsers, but overlooked that the CMakeBuildStep does
additional line-based parsing. As a result, the stdout -> stderr
redirection for ninja output was broken.
Change-Id: Iafbbce9a3f9c0383812a9e4c129c1d94fa907b73
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakebuildstep.cpp | 58 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakebuildstep.h | 2 |
2 files changed, 36 insertions, 24 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index aa9c3f6e6e..287514c4df 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -268,33 +268,45 @@ QString CMakeBuildStep::defaultBuildTarget() const return allTarget(); } -void CMakeBuildStep::stdOutput(const QString &line) -{ - if (m_percentProgress.indexIn(line) != -1) { - AbstractProcessStep::stdOutput(line); - bool ok = false; - int percent = m_percentProgress.cap(1).toInt(&ok); - if (ok) - emit progress(percent, QString()); - return; - } else if (m_ninjaProgress.indexIn(line) != -1) { - AbstractProcessStep::stdOutput(line); - m_useNinja = true; - bool ok = false; - int done = m_ninjaProgress.cap(1).toInt(&ok); - if (ok) { - int all = m_ninjaProgress.cap(2).toInt(&ok); - if (ok && all != 0) { - const int percent = static_cast<int>(100.0 * done/all); +void CMakeBuildStep::stdOutput(const QString &output) +{ + int offset = 0; + while (offset != -1) { + const int newlinePos = output.indexOf('\n', offset); + QString line; + if (newlinePos == -1) { + line = output.mid(offset); + offset = -1; + } else { + line = output.mid(offset, newlinePos - offset + 1); + offset = newlinePos + 1; + } + if (m_percentProgress.indexIn(line) != -1) { + AbstractProcessStep::stdOutput(line); + bool ok = false; + int percent = m_percentProgress.cap(1).toInt(&ok); + if (ok) emit progress(percent, QString()); + continue; + } else if (m_ninjaProgress.indexIn(line) != -1) { + AbstractProcessStep::stdOutput(line); + m_useNinja = true; + bool ok = false; + int done = m_ninjaProgress.cap(1).toInt(&ok); + if (ok) { + int all = m_ninjaProgress.cap(2).toInt(&ok); + if (ok && all != 0) { + const int percent = static_cast<int>(100.0 * done/all); + emit progress(percent, QString()); + } } + continue; } - return; + if (m_useNinja) + AbstractProcessStep::stdError(line); + else + AbstractProcessStep::stdOutput(line); } - if (m_useNinja) - AbstractProcessStep::stdError(line); - else - AbstractProcessStep::stdOutput(line); } QString CMakeBuildStep::buildTarget() const diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.h b/src/plugins/cmakeprojectmanager/cmakebuildstep.h index 1e5a4e7100..f2a650fe78 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.h @@ -77,7 +77,7 @@ protected: bool fromMap(const QVariantMap &map) override; // For parsing [ 76%] - void stdOutput(const QString &line) override; + void stdOutput(const QString &output) override; private: void ctor(ProjectExplorer::BuildStepList *bsl); |