diff options
author | BogDan Vatra <bogdan@kdab.com> | 2015-11-04 15:52:55 +0200 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2015-11-20 16:40:16 +0000 |
commit | e077e514c087f3f7136e35ddb5a0ca488c4bf901 (patch) | |
tree | 0115fef1d2c6ee80b97fd00b65fa669517451ad4 /src/lib/corelib/buildgraph/processcommandexecutor.cpp | |
parent | 19adef57e5e7f694f37931c49ed07c9825b56ebc (diff) |
Make it easy to redirect the commands outputs to files.
Change-Id: I0516527408d44b8f78d8da1fc65cdf609babfbc6
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/lib/corelib/buildgraph/processcommandexecutor.cpp')
-rw-r--r-- | src/lib/corelib/buildgraph/processcommandexecutor.cpp | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp index 3db3e496b..13bbceb36 100644 --- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp +++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp @@ -208,19 +208,38 @@ void ProcessCommandExecutor::sendProcessOutput() result.d->error = m_process.error(); QString errorString = m_process.errorString(); - QString tmp = filterProcessOutput(m_process.readAllStandardOutput(), - processCommand()->stdoutFilterFunction()); - if (!tmp.isEmpty()) { - if (tmp.endsWith(QLatin1Char('\n'))) - tmp.chop(1); - result.d->stdOut = tmp.split(QLatin1Char('\n')); + QByteArray content = m_process.readAllStandardOutput(); + QString tmp; + if (!processCommand()->stdoutFilterFunction().isEmpty()) + tmp = filterProcessOutput(content, processCommand()->stdoutFilterFunction()); + + if (!processCommand()->stdoutFilePath().isEmpty()) { + result.d->error = processCommand()->saveStdout(tmp.isEmpty() ? content : tmp.toLocal8Bit()); + } else { + if (tmp.isEmpty()) + tmp = QString::fromLocal8Bit(content); + if (!tmp.isEmpty()) { + if (tmp.endsWith(QLatin1Char('\n'))) + tmp.chop(1); + result.d->stdOut = tmp.split(QLatin1Char('\n')); + } } - tmp = filterProcessOutput(m_process.readAllStandardError(), - processCommand()->stderrFilterFunction()); - if (!tmp.isEmpty()) { - if (tmp.endsWith(QLatin1Char('\n'))) - tmp.chop(1); - result.d->stdErr = tmp.split(QLatin1Char('\n')); + + tmp.clear(); + content = m_process.readAllStandardError(); + if (!processCommand()->stderrFilterFunction().isEmpty()) + tmp = filterProcessOutput(content, processCommand()->stderrFilterFunction()); + + if (!processCommand()->stderrFilePath().isEmpty()) { + result.d->error = processCommand()->saveStderr(tmp.isEmpty() ? content : tmp.toLocal8Bit()); + } else { + if (tmp.isEmpty()) + tmp = QString::fromLocal8Bit(content); + if (!tmp.isEmpty()) { + if (tmp.endsWith(QLatin1Char('\n'))) + tmp.chop(1); + result.d->stdErr = tmp.split(QLatin1Char('\n')); + } } const bool processError = result.error() != QProcess::UnknownError; const bool failureExit = quint32(m_process.exitCode()) |