diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-06-09 14:02:47 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-06-14 15:53:55 (GMT) |
commit | b8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421 (patch) | |
tree | e2874af8d0a86cd73221f8ccb5bc33f05782e122 /Source/cmUVProcessChain.cxx | |
parent | ec81d40be437a0ca2362f3b8c84dbfbf7fe6a2b3 (diff) | |
download | CMake-b8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421.zip CMake-b8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421.tar.gz CMake-b8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421.tar.bz2 |
cmUVProcessChain: Return output and error streams as file descriptors
Diffstat (limited to 'Source/cmUVProcessChain.cxx')
-rw-r--r-- | Source/cmUVProcessChain.cxx | 60 |
1 files changed, 12 insertions, 48 deletions
diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index cf4475b..3de7ae5 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -17,36 +17,15 @@ #include "cmGetPipes.h" #include "cmUVHandlePtr.h" -#include "cmUVStreambuf.h" struct cmUVProcessChain::InternalData { - struct BasicStreamData + struct StreamData { - cmUVStreambuf Streambuf; - cm::uv_pipe_ptr BuiltinStream; + int BuiltinStream = -1; uv_stdio_container_t Stdio; }; - template <typename IOStream> - struct StreamData : public BasicStreamData - { - StreamData() - : BuiltinIOStream(&this->Streambuf) - { - } - - IOStream BuiltinIOStream; - - IOStream* GetBuiltinStream() - { - if (this->BuiltinStream.get()) { - return &this->BuiltinIOStream; - } - return nullptr; - } - }; - struct ProcessData { cmUVProcessChain::InternalData* Data; @@ -64,9 +43,9 @@ struct cmUVProcessChain::InternalData cm::uv_loop_ptr Loop; - StreamData<std::ostream> InputStreamData; - StreamData<std::istream> OutputStreamData; - StreamData<std::istream> ErrorStreamData; + StreamData InputStreamData; + StreamData OutputStreamData; + StreamData ErrorStreamData; cm::uv_pipe_ptr TempOutputPipe; cm::uv_pipe_ptr TempErrorPipe; @@ -215,12 +194,7 @@ bool cmUVProcessChain::InternalData::Prepare( return false; } - if (errorData.BuiltinStream.init(*this->Loop, 0) < 0) { - return false; - } - if (uv_pipe_open(errorData.BuiltinStream, pipeFd[0]) < 0) { - return false; - } + errorData.BuiltinStream = pipeFd[0]; errorData.Stdio.flags = UV_INHERIT_FD; errorData.Stdio.data.fd = pipeFd[1]; @@ -231,7 +205,6 @@ bool cmUVProcessChain::InternalData::Prepare( return false; } - errorData.Streambuf.open(errorData.BuiltinStream); break; } @@ -251,6 +224,7 @@ bool cmUVProcessChain::InternalData::Prepare( case cmUVProcessChainBuilder::Builtin: if (this->Builder->MergedBuiltinStreams) { + outputData.BuiltinStream = errorData.BuiltinStream; outputData.Stdio.flags = UV_INHERIT_FD; outputData.Stdio.data.fd = errorData.Stdio.data.fd; } else { @@ -259,12 +233,7 @@ bool cmUVProcessChain::InternalData::Prepare( return false; } - if (outputData.BuiltinStream.init(*this->Loop, 0) < 0) { - return false; - } - if (uv_pipe_open(outputData.BuiltinStream, pipeFd[0]) < 0) { - return false; - } + outputData.BuiltinStream = pipeFd[0]; outputData.Stdio.flags = UV_INHERIT_FD; outputData.Stdio.data.fd = pipeFd[1]; @@ -274,8 +243,6 @@ bool cmUVProcessChain::InternalData::Prepare( if (uv_pipe_open(this->TempOutputPipe, outputData.Stdio.data.fd) < 0) { return false; } - - outputData.Streambuf.open(outputData.BuiltinStream); } break; @@ -411,17 +378,14 @@ uv_loop_t& cmUVProcessChain::GetLoop() return *this->Data->Loop; } -std::istream* cmUVProcessChain::OutputStream() +int cmUVProcessChain::OutputStream() { - if (this->Data->Builder->MergedBuiltinStreams) { - return this->Data->ErrorStreamData.GetBuiltinStream(); - } - return this->Data->OutputStreamData.GetBuiltinStream(); + return this->Data->OutputStreamData.BuiltinStream; } -std::istream* cmUVProcessChain::ErrorStream() +int cmUVProcessChain::ErrorStream() { - return this->Data->ErrorStreamData.GetBuiltinStream(); + return this->Data->ErrorStreamData.BuiltinStream; } bool cmUVProcessChain::Valid() const |