summaryrefslogtreecommitdiffstats
path: root/Source/cmUVProcessChain.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-05-26 19:52:01 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2023-05-26 19:52:01 (GMT)
commitec80090ce347f639fc893d0f56385da3c2ad28ec (patch)
tree3efdf6d74ca8f7737724d0bfe80b673ccc33eb83 /Source/cmUVProcessChain.cxx
parent67bb1ee50cde981dd36f2b9964013c330f7e92fe (diff)
downloadCMake-ec80090ce347f639fc893d0f56385da3c2ad28ec.zip
CMake-ec80090ce347f639fc893d0f56385da3c2ad28ec.tar.gz
CMake-ec80090ce347f639fc893d0f56385da3c2ad28ec.tar.bz2
cmUVProcessChain: Add option for merged output and error
Diffstat (limited to 'Source/cmUVProcessChain.cxx')
-rw-r--r--Source/cmUVProcessChain.cxx59
1 files changed, 37 insertions, 22 deletions
diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx
index 5d00544..257c054 100644
--- a/Source/cmUVProcessChain.cxx
+++ b/Source/cmUVProcessChain.cxx
@@ -140,6 +140,12 @@ cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetExternalStream(
return *this;
}
+cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetMergedBuiltinStreams()
+{
+ this->MergedBuiltinStreams = true;
+ return this->SetBuiltinStream(Stream_OUTPUT).SetBuiltinStream(Stream_ERROR);
+}
+
cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetWorkingDirectory(
std::string dir)
{
@@ -181,27 +187,6 @@ bool cmUVProcessChain::InternalData::Prepare(
{
this->Builder = builder;
- auto const& output =
- this->Builder->Stdio[cmUVProcessChainBuilder::Stream_OUTPUT];
- auto& outputData = this->OutputStreamData;
- switch (output.Type) {
- case cmUVProcessChainBuilder::None:
- outputData.Stdio.flags = UV_IGNORE;
- break;
-
- case cmUVProcessChainBuilder::Builtin:
- outputData.BuiltinStream.init(*this->Loop, 0);
- outputData.Stdio.flags =
- static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
- outputData.Stdio.data.stream = outputData.BuiltinStream;
- break;
-
- case cmUVProcessChainBuilder::External:
- outputData.Stdio.flags = UV_INHERIT_FD;
- outputData.Stdio.data.fd = output.FileDescriptor;
- break;
- }
-
auto const& error =
this->Builder->Stdio[cmUVProcessChainBuilder::Stream_ERROR];
auto& errorData = this->ErrorStreamData;
@@ -231,6 +216,32 @@ bool cmUVProcessChain::InternalData::Prepare(
break;
}
+ auto const& output =
+ this->Builder->Stdio[cmUVProcessChainBuilder::Stream_OUTPUT];
+ auto& outputData = this->OutputStreamData;
+ switch (output.Type) {
+ case cmUVProcessChainBuilder::None:
+ outputData.Stdio.flags = UV_IGNORE;
+ break;
+
+ case cmUVProcessChainBuilder::Builtin:
+ if (this->Builder->MergedBuiltinStreams) {
+ outputData.Stdio.flags = UV_INHERIT_FD;
+ outputData.Stdio.data.fd = errorData.Stdio.data.fd;
+ } else {
+ outputData.BuiltinStream.init(*this->Loop, 0);
+ outputData.Stdio.flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ outputData.Stdio.data.stream = outputData.BuiltinStream;
+ }
+ break;
+
+ case cmUVProcessChainBuilder::External:
+ outputData.Stdio.flags = UV_INHERIT_FD;
+ outputData.Stdio.data.fd = output.FileDescriptor;
+ break;
+ }
+
return true;
}
@@ -299,7 +310,8 @@ bool cmUVProcessChain::InternalData::AddCommand(
bool cmUVProcessChain::InternalData::Finish()
{
if (this->Builder->Stdio[cmUVProcessChainBuilder::Stream_OUTPUT].Type ==
- cmUVProcessChainBuilder::Builtin) {
+ cmUVProcessChainBuilder::Builtin &&
+ !this->Builder->MergedBuiltinStreams) {
this->OutputStreamData.Streambuf.open(
this->OutputStreamData.BuiltinStream);
}
@@ -349,6 +361,9 @@ uv_loop_t& cmUVProcessChain::GetLoop()
std::istream* cmUVProcessChain::OutputStream()
{
+ if (this->Data->Builder->MergedBuiltinStreams) {
+ return this->Data->ErrorStreamData.GetBuiltinStream();
+ }
return this->Data->OutputStreamData.GetBuiltinStream();
}