mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
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:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user