Skip to content

Commit 76ee4cb

Browse files
committed
migrate run method with new caching mechanism
1 parent 3ff8a41 commit 76ee4cb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/bootstrap/src/utils/execution_context.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,24 @@ impl ExecutionContext {
146146
stdout: OutputMode,
147147
stderr: OutputMode,
148148
) -> CommandOutput {
149-
self.start(command, stdout, stderr).wait_for_output(self)
149+
let cache_key = command.cache_key();
150+
151+
if let Some(cached_output) = self.command_cache.get(&cache_key) {
152+
command.mark_as_executed();
153+
if self.dry_run() && !command.run_always {
154+
return CommandOutput::default();
155+
}
156+
self.verbose(|| println!("Cache hit: {:?}", command));
157+
return cached_output;
158+
}
159+
160+
let output = self.start(command, stdout, stderr).wait_for_output(self);
161+
162+
if output != CommandOutput::default() {
163+
self.command_cache.insert(cache_key, output.clone());
164+
}
165+
166+
output
150167
}
151168

152169
fn fail(&self, message: &str, output: CommandOutput) -> ! {

0 commit comments

Comments
 (0)