about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/bootstrap/src/utils/exec.rs3
-rw-r--r--src/bootstrap/src/utils/execution_context.rs7
2 files changed, 4 insertions, 6 deletions
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs
index 11d786523c4..29b32f548d1 100644
--- a/src/bootstrap/src/utils/exec.rs
+++ b/src/bootstrap/src/utils/exec.rs
@@ -71,6 +71,9 @@ pub struct CommandCacheKey {
 ///
 /// Bootstrap will print a debug log to stdout if the command fails and failure is not allowed.
 ///
+/// By default, command executions are cached based on their workdir, program, arguments, and environment variables.
+/// This avoids re-running identical commands unnecessarily, unless caching is explicitly disabled.
+///
 /// [allow_failure]: BootstrapCommand::allow_failure
 /// [delay_failure]: BootstrapCommand::delay_failure
 pub struct BootstrapCommand {
diff --git a/src/bootstrap/src/utils/execution_context.rs b/src/bootstrap/src/utils/execution_context.rs
index 068a8db218c..e25dfb501cf 100644
--- a/src/bootstrap/src/utils/execution_context.rs
+++ b/src/bootstrap/src/utils/execution_context.rs
@@ -122,19 +122,15 @@ impl ExecutionContext {
         stdout: OutputMode,
         stderr: OutputMode,
     ) -> DeferredCommand<'a> {
+        command.mark_as_executed();
         let cache_key = command.cache_key();
 
         if let Some(cached_output) = cache_key.as_ref().and_then(|key| self.command_cache.get(key))
         {
-            command.mark_as_executed();
-
             self.verbose(|| println!("Cache hit: {command:?}"));
-
             return DeferredCommand { state: CommandState::Cached(cached_output) };
         }
 
-        command.mark_as_executed();
-
         let created_at = command.get_created_location();
         let executed_at = std::panic::Location::caller();
 
@@ -254,7 +250,6 @@ impl<'a> DeferredCommand<'a> {
         };
 
         let created_at = command.get_created_location();
-        let executed_at = executed_at;
 
         let mut message = String::new();