summaryrefslogtreecommitdiffstats
path: root/src/executor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/executor.rs')
-rw-r--r--src/executor.rs35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/executor.rs b/src/executor.rs
index c616c0b..350acc3 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -7,7 +7,7 @@ pub struct Executor<'a> {
tasks: &'a TaskMap,
tasks_blocked: HashSet<TaskRef>,
tasks_runnable: Vec<TaskRef>,
- tasks_done: HashSet<TaskRef>,
+ tasks_done: HashMap<TaskRef, TaskOutput>,
rdeps: HashMap<TaskRef, Vec<TaskRef>>,
}
@@ -17,7 +17,7 @@ impl<'a> Executor<'a> {
tasks,
tasks_blocked: HashSet::new(),
tasks_runnable: Vec::new(),
- tasks_done: HashSet::new(),
+ tasks_done: HashMap::new(),
rdeps: HashMap::new(),
};
@@ -44,17 +44,39 @@ impl<'a> Executor<'a> {
task_def
.depends
.iter()
- .all(|dep| self.tasks_done.contains(dep))
+ .all(|dep| self.tasks_done.contains_key(dep))
+ }
+
+ fn task_deps(&self, task: &TaskRef) -> HashMap<TaskRef, OutputHash> {
+ let task_def = self.tasks.get(&task).expect("Invalid TaskRef");
+ task_def
+ .depends
+ .iter()
+ .map(|dep| {
+ (
+ dep.clone(),
+ self.tasks_done
+ .get(dep)
+ .expect("Invalid dependency")
+ .output_hash,
+ )
+ })
+ .collect()
}
fn run_one(&mut self, runner: &impl runner::Runner) -> runner::Result<()> {
let task = self.tasks_runnable.pop().expect("No runnable tasks left");
+ let task_deps = self.task_deps(&task);
- let _hash = runner.run(self.tasks, &task)?;
+ let hash = runner.run(self.tasks, &task)?;
+ let output = TaskOutput {
+ task_ref: task.clone(),
+ depends: task_deps,
+ output_hash: hash,
+ };
let rdeps = self.rdeps.get(&task);
-
- self.tasks_done.insert(task);
+ self.tasks_done.insert(task, output);
for rdep in rdeps.unwrap_or(&Vec::new()) {
if !self.tasks_blocked.contains(rdep) {
@@ -75,6 +97,7 @@ impl<'a> Executor<'a> {
}
assert!(self.tasks_blocked.is_empty(), "No runnable tasks left");
+ println!("{}", serde_json::to_string_pretty(&self.tasks_done)?);
Ok(())
}
}