Skip to content

Commit 555a125

Browse files
committed
add should cache to bootstrap command
1 parent c6c67ee commit 555a125

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub struct BootstrapCommand {
7373
args: Vec<OsString>,
7474
envs: Vec<(OsString, OsString)>,
7575
cwd: Option<PathBuf>,
76+
should_cache: bool,
7677

7778
command: Command,
7879
pub failure_behavior: BehaviorOnFailure,
@@ -86,15 +87,18 @@ pub struct BootstrapCommand {
8687
impl<'a> BootstrapCommand {
8788
#[track_caller]
8889
pub fn new<S: AsRef<OsStr>>(program: S) -> Self {
89-
Command::new(program).into()
90+
Self { should_cache: true, ..Command::new(program).into() }
9091
}
91-
9292
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self {
9393
self.args.push(arg.as_ref().to_os_string());
9494
self.command.arg(arg.as_ref());
9595
self
9696
}
9797

98+
pub fn should_cache(&self) -> bool {
99+
self.should_cache
100+
}
101+
98102
pub fn args<I, S>(&mut self, args: I) -> &mut Self
99103
where
100104
I: IntoIterator<Item = S>,
@@ -197,6 +201,7 @@ impl<'a> BootstrapCommand {
197201
// We don't know what will happen with the returned command, so we need to mark this
198202
// command as executed proactively.
199203
self.mark_as_executed();
204+
self.should_cache = false;
200205
&mut self.command
201206
}
202207

@@ -250,6 +255,7 @@ impl From<Command> for BootstrapCommand {
250255
args: Vec::new(),
251256
envs: Vec::new(),
252257
cwd: None,
258+
should_cache: false,
253259
command,
254260
failure_behavior: BehaviorOnFailure::Exit,
255261
run_always: false,

0 commit comments

Comments
 (0)