summaryrefslogtreecommitdiffstats
path: root/Source
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
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')
-rw-r--r--Source/cmUVProcessChain.cxx59
-rw-r--r--Source/cmUVProcessChain.h2
2 files changed, 39 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();
}
diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h
index 44a4888..3ade3fd 100644
--- a/Source/cmUVProcessChain.h
+++ b/Source/cmUVProcessChain.h
@@ -30,6 +30,7 @@ public:
const std::vector<std::string>& arguments);
cmUVProcessChainBuilder& SetNoStream(Stream stdio);
cmUVProcessChainBuilder& SetBuiltinStream(Stream stdio);
+ cmUVProcessChainBuilder& SetMergedBuiltinStreams();
cmUVProcessChainBuilder& SetExternalStream(Stream stdio, int fd);
cmUVProcessChainBuilder& SetWorkingDirectory(std::string dir);
@@ -59,6 +60,7 @@ private:
std::array<StdioConfiguration, 3> Stdio;
std::vector<ProcessConfiguration> Processes;
std::string WorkingDirectory;
+ bool MergedBuiltinStreams = false;
};
class cmUVProcessChain