summaryrefslogtreecommitdiffstats
path: root/src/executor.rs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-10-24 22:40:08 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-10-24 23:58:03 +0200
commita1a185370da27f2cc3df84d3a8d7141f9ce7db16 (patch)
tree6904f6f0549e89d160cbe635713e2864df25c21a /src/executor.rs
parent524985f9449eb2f3a1d01b5f88dc74123d40c43a (diff)
downloadrebel-a1a185370da27f2cc3df84d3a8d7141f9ce7db16.tar
rebel-a1a185370da27f2cc3df84d3a8d7141f9ce7db16.zip
Split defintions used by both runner and executor into separate crate
Also get rid of the Runner trait - different runner implementations do not make sense with our current design.
Diffstat (limited to 'src/executor.rs')
-rw-r--r--src/executor.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/executor.rs b/src/executor.rs
index a13b358..9828543 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -3,14 +3,14 @@ use std::collections::{HashMap, HashSet};
use indoc::indoc;
use ipc_channel::ipc;
+use common::{error::*, string_hash::*, types::*};
+
use crate::{
context::{Context, TaskRef},
paths, resolve,
- runner::{self, TaskOutput},
+ runner::Runner,
task::*,
template::TemplateEngine,
- types::*,
- util::error::*,
};
pub struct Executor<'ctx> {
@@ -66,13 +66,13 @@ impl<'ctx> Executor<'ctx> {
.all(|dep| self.tasks_done.contains_key(&dep))
}
- fn fetch_deps(&self, task: &TaskRef<'ctx>) -> Result<Vec<runner::Dependency>> {
+ fn fetch_deps(&self, task: &TaskRef<'ctx>) -> Result<Vec<Dependency>> {
let task_def = &self.ctx[task.id];
task_def
.fetch
.iter()
.map(|Fetch { name, sha256 }| {
- Ok(runner::Dependency::Fetch {
+ Ok(Dependency::Fetch {
name: self.tpl.eval_raw(name, &task.args).with_context(|| {
format!("Failed to evaluate fetch filename for task {}", task)
})?,
@@ -82,7 +82,7 @@ impl<'ctx> Executor<'ctx> {
.collect()
}
- fn task_deps(&self, task: &TaskRef<'ctx>) -> Result<HashSet<runner::Dependency>> {
+ fn task_deps(&self, task: &TaskRef<'ctx>) -> Result<HashSet<Dependency>> {
Ok(self
.fetch_deps(task)?
.into_iter()
@@ -96,7 +96,7 @@ impl<'ctx> Executor<'ctx> {
.expect("invalid runtime depends of build_depends")
.into_iter()
.filter_map(|dep| self.tasks_done[&dep.task].outputs.get(dep.output))
- .map(|&output| runner::Dependency::Task {
+ .map(|&output| Dependency::Task {
output,
path: "".to_string(),
}),
@@ -111,7 +111,7 @@ impl<'ctx> Executor<'ctx> {
.expect("invalid runtime depends of host_depends")
.into_iter()
.filter_map(|dep| self.tasks_done[&dep.task].outputs.get(dep.output))
- .map(|&output| runner::Dependency::Task {
+ .map(|&output| Dependency::Task {
output,
path: paths::abs(paths::TASK_SYSROOT),
}),
@@ -208,7 +208,7 @@ impl<'ctx> Executor<'ctx> {
fn spawn_one(
&self,
task_ref: &TaskRef<'ctx>,
- runner: &impl runner::Runner,
+ runner: &Runner,
) -> Result<ipc::IpcReceiver<Result<TaskOutput>>> {
let task_def = &self.ctx[task_ref.id];
let task_deps = self.task_deps(task_ref)?;
@@ -235,7 +235,7 @@ impl<'ctx> Executor<'ctx> {
format!("Failed to evaluate command template for task {}", task_ref)
})?;
- let task = runner::Task {
+ let task = Task {
label: format!("{:#}", task_ref),
command,
inherit: inherit_chain,
@@ -246,7 +246,7 @@ impl<'ctx> Executor<'ctx> {
Ok(runner.spawn(&task))
}
- fn run_tasks(&mut self, runner: &impl runner::Runner) -> Result<()> {
+ fn run_tasks(&mut self, runner: &Runner) -> Result<()> {
while let Some(task_ref) = self.tasks_runnable.pop() {
let channel = self.spawn_one(&task_ref, runner)?;
let id = self
@@ -312,7 +312,7 @@ impl<'ctx> Executor<'ctx> {
Ok(())
}
- pub fn run(&mut self, runner: &impl runner::Runner) -> Result<()> {
+ pub fn run(&mut self, runner: &Runner) -> Result<()> {
while !(self.tasks_runnable.is_empty() && self.tasks_running.is_empty()) {
self.run_tasks(runner)?;
self.wait_for_task()?;