cmWorkerPool: Allow capturing process stderr separately

JobT::RunProcess always merged the process stderr into
ProcessResultT::StdOut. That is fine for jobs that only log the output,
but not for jobs that consume stdout as data. Add a mergedOutput
parameter that defaults to the previous behavior.

Issue: #28093
This commit is contained in:
Joerg Bornemann
2026-09-18 11:34:49 +02:00
parent 833d9466d7
commit 1c1258ad95
2 changed files with 12 additions and 6 deletions
+8 -5
View File
@@ -401,7 +401,7 @@ public:
*/
bool RunProcess(cmWorkerPool::ProcessResultT& result,
std::vector<std::string> command,
std::string const& workingDirectory);
std::string const& workingDirectory, bool mergedOutput);
private:
// -- Libuv callbacks
@@ -434,7 +434,8 @@ cmWorkerPoolWorker::~cmWorkerPoolWorker()
bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result,
std::vector<std::string> command,
std::string const& workingDirectory)
std::string const& workingDirectory,
bool mergedOutput)
{
if (command.empty()) {
return false;
@@ -443,7 +444,7 @@ bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result,
{
std::lock_guard<std::mutex> lock(this->Proc_.Mutex);
this->Proc_.ROP = cm::make_unique<cmUVReadOnlyProcess>();
this->Proc_.ROP->setup(&result, true, std::move(command),
this->Proc_.ROP->setup(&result, mergedOutput, std::move(command),
workingDirectory);
}
// Send asynchronous process start request to libuv loop
@@ -737,11 +738,13 @@ cmWorkerPool::JobT::~JobT() = default;
bool cmWorkerPool::JobT::RunProcess(ProcessResultT& result,
std::vector<std::string> command,
std::string const& workingDirectory)
std::string const& workingDirectory,
bool mergedOutput)
{
// Get worker by index
auto* worker = this->Pool_->Int_->Workers.at(this->WorkerIndex_).get();
return worker->RunProcess(result, std::move(command), workingDirectory);
return worker->RunProcess(result, std::move(command), workingDirectory,
mergedOutput);
}
cmWorkerPool::cmWorkerPool()
+4 -1
View File
@@ -101,9 +101,12 @@ public:
/**
* Run an external read only process.
* Use only during JobT::Process() call!
* @arg mergedOutput Append the process stderr to ProcessResultT::StdOut
* instead of ProcessResultT::StdErr.
*/
bool RunProcess(ProcessResultT& result, std::vector<std::string> command,
std::string const& workingDirectory);
std::string const& workingDirectory,
bool mergedOutput = true);
private:
//! Needs access to Work()