| 189 | } |
| 190 | |
| 191 | bool cmUVProcessChain::InternalData::Prepare( |
| 192 | cmUVProcessChainBuilder const* builder) |
| 193 | { |
| 194 | this->Builder = builder; |
| 195 | |
| 196 | if (this->Builder->Loop) { |
| 197 | this->Loop = this->Builder->Loop; |
| 198 | } else { |
| 199 | this->BuiltinLoop.init(); |
| 200 | this->Loop = this->BuiltinLoop; |
| 201 | } |
| 202 | |
| 203 | auto const& input = |
| 204 | this->Builder->Stdio[cmUVProcessChainBuilder::Stream_INPUT]; |
| 205 | auto& inputData = this->InputStreamData; |
| 206 | switch (input.Type) { |
| 207 | case cmUVProcessChainBuilder::None: |
| 208 | inputData.Stdio.flags = UV_IGNORE; |
| 209 | break; |
| 210 | |
| 211 | case cmUVProcessChainBuilder::Builtin: { |
| 212 | // FIXME |
| 213 | break; |
| 214 | } |
| 215 | |
| 216 | case cmUVProcessChainBuilder::External: |
| 217 | inputData.Stdio.flags = UV_INHERIT_FD; |
| 218 | inputData.Stdio.data.fd = input.FileDescriptor; |
| 219 | break; |
| 220 | } |
| 221 | |
| 222 | auto const& output = |
| 223 | this->Builder->Stdio[cmUVProcessChainBuilder::Stream_OUTPUT]; |
| 224 | auto& outputData = this->OutputStreamData; |
| 225 | switch (output.Type) { |
| 226 | case cmUVProcessChainBuilder::None: |
| 227 | outputData.Stdio.flags = UV_IGNORE; |
| 228 | break; |
| 229 | |
| 230 | case cmUVProcessChainBuilder::Builtin: { |
| 231 | int pipeFd[2]; |
| 232 | if (cmGetPipes(pipeFd) < 0) { |
| 233 | return false; |
| 234 | } |
| 235 | |
| 236 | if (outputData.BuiltinStream.init(*this->Loop, 0) < 0) { |
| 237 | return false; |
| 238 | } |
| 239 | if (uv_pipe_open(outputData.BuiltinStream, pipeFd[0]) < 0) { |
| 240 | return false; |
| 241 | } |
| 242 | |
| 243 | if (this->TempOutputPipe.init(*this->Loop, 0) < 0) { |
| 244 | return false; |
| 245 | } |
| 246 | if (uv_pipe_open(this->TempOutputPipe, pipeFd[1]) < 0) { |
| 247 | return false; |
| 248 | } |
no test coverage detected