1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
8 #include <cstddef> // IWYU pragma: keep
18 class cmUVProcessChain
;
20 class cmUVProcessChainBuilder
30 cmUVProcessChainBuilder();
32 cmUVProcessChainBuilder
& AddCommand(
33 const std::vector
<std::string
>& arguments
);
34 cmUVProcessChainBuilder
& SetBuiltinLoop();
35 cmUVProcessChainBuilder
& SetExternalLoop(uv_loop_t
& loop
);
36 cmUVProcessChainBuilder
& SetNoStream(Stream stdio
);
37 cmUVProcessChainBuilder
& SetBuiltinStream(Stream stdio
);
38 cmUVProcessChainBuilder
& SetMergedBuiltinStreams();
39 cmUVProcessChainBuilder
& SetExternalStream(Stream stdio
, int fd
);
40 cmUVProcessChainBuilder
& SetExternalStream(Stream stdio
, FILE* stream
);
41 cmUVProcessChainBuilder
& SetWorkingDirectory(std::string dir
);
43 uv_loop_t
* GetLoop() const;
45 cmUVProcessChain
Start() const;
55 friend class cmUVProcessChain
;
57 struct StdioConfiguration
59 StdioType Type
= None
;
60 int FileDescriptor
= -1;
63 struct ProcessConfiguration
65 std::vector
<std::string
> Arguments
;
68 std::array
<StdioConfiguration
, 3> Stdio
;
69 std::vector
<ProcessConfiguration
> Processes
;
70 std::string WorkingDirectory
;
71 bool MergedBuiltinStreams
= false;
72 uv_loop_t
* Loop
= nullptr;
75 class cmUVProcessChain
78 enum class ExceptionCode
96 std::pair
<ExceptionCode
, std::string
> GetException() const;
99 cmUVProcessChain(const cmUVProcessChain
& other
) = delete;
100 cmUVProcessChain(cmUVProcessChain
&& other
) noexcept
;
104 cmUVProcessChain
& operator=(const cmUVProcessChain
& other
) = delete;
105 cmUVProcessChain
& operator=(cmUVProcessChain
&& other
) noexcept
;
107 uv_loop_t
& GetLoop();
109 // FIXME: Add stdin support
114 bool Wait(uint64_t milliseconds
= 0);
115 std::vector
<const Status
*> GetStatus() const;
116 const Status
& GetStatus(std::size_t index
) const;
117 bool Finished() const;
120 friend class cmUVProcessChainBuilder
;
125 std::unique_ptr
<InternalData
> Data
;