Skip to content

Commit 16bc870

Browse files
committed
add start methods in exec
1 parent 7889332 commit 16bc870

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
//!
33
//! This module provides a structured way to execute and manage commands efficiently,
44
//! ensuring controlled failure handling and output management.
5-
5+
#![allow(warnings)]
66
use std::ffi::OsStr;
77
use std::fmt::{Debug, Formatter};
88
use std::path::Path;
9-
use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio};
9+
use std::process::{Child, Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio};
1010

1111
use build_helper::ci::CiEnv;
1212
use build_helper::drop_bomb::DropBomb;
1313

14-
use super::execution_context::ExecutionContext;
14+
use super::execution_context::{DeferredCommand, ExecutionContext};
1515

1616
/// What should be done when the command fails.
1717
#[derive(Debug, Copy, Clone)]
@@ -158,6 +158,21 @@ impl BootstrapCommand {
158158
exec_ctx.as_ref().run(self, OutputMode::Capture, OutputMode::Print)
159159
}
160160

161+
/// Spawn the command in background, while capturing and returning all its output.
162+
#[track_caller]
163+
pub fn start_capture(&mut self, exec_ctx: impl AsRef<ExecutionContext>) -> DeferredCommand {
164+
exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Capture)
165+
}
166+
167+
/// Spawn the command in background, while capturing and returning stdout, and printing stderr.
168+
#[track_caller]
169+
pub fn start_capture_stdout(
170+
&mut self,
171+
exec_ctx: impl AsRef<ExecutionContext>,
172+
) -> DeferredCommand {
173+
exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Print)
174+
}
175+
161176
/// Provides access to the stdlib Command inside.
162177
/// FIXME: This function should be eventually removed from bootstrap.
163178
pub fn as_command_mut(&mut self) -> &mut Command {

0 commit comments

Comments
 (0)