summaryrefslogtreecommitdiffstats
path: root/src/executor.rs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-09-26 15:33:58 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-09-26 15:33:58 +0200
commit8564c639f382b46382cfb1a01af70f2202fe168f (patch)
tree49f7e0b0abdc7bcee56cab9193cfd6045bb2ea27 /src/executor.rs
parent3995fe99a9a2be2e4c7b5ce25c80ea7899f7230f (diff)
downloadrebel-8564c639f382b46382cfb1a01af70f2202fe168f.tar
rebel-8564c639f382b46382cfb1a01af70f2202fe168f.zip
Move defintion of globals into context
Globals like "destdir" and "sysroot" are now handled like "build". In addition, their value is determined based on the "paths" module.
Diffstat (limited to 'src/executor.rs')
-rw-r--r--src/executor.rs34
1 files changed, 4 insertions, 30 deletions
diff --git a/src/executor.rs b/src/executor.rs
index bb29edd..6bd90b5 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -3,7 +3,6 @@ use std::collections::{HashMap, HashSet};
use serde::{Deserialize, Serialize};
use crate::{
- args::{self, TaskArgs},
context::{Context, TaskRef},
paths, resolve, runner,
task::*,
@@ -12,13 +11,6 @@ use crate::{
util::{cjson, error::*, fs},
};
-const BASE_ARGS: &[(&str, &str)] = &[
- ("workdir", "/build/work"),
- ("dldir", "/build/downloads"),
- ("destdir", "/build/dest"),
- ("sysroot", "/opt/toolchain/sysroot"),
-];
-
fn input_hash(task: &runner::TaskInput) -> InputHash {
InputHash(StringHash(
cjson::digest::<InputHasher, _>(task).unwrap().into(),
@@ -63,27 +55,17 @@ pub struct Executor<'ctx> {
tasks_runnable: Vec<TaskRef<'ctx>>,
tasks_done: HashMap<TaskRef<'ctx>, TaskMeta>,
rdeps: HashMap<TaskRef<'ctx>, Vec<TaskRef<'ctx>>>,
- base_args: TaskArgs,
tpl: TemplateEngine,
}
impl<'ctx> Executor<'ctx> {
pub fn new(ctx: &'ctx Context, taskset: HashSet<TaskRef<'ctx>>) -> Result<Self> {
- let base_args = TaskArgs(
- BASE_ARGS
- .iter()
- .copied()
- .map(|(k, v)| args::arg(k, v))
- .collect(),
- );
-
let mut exc = Executor {
ctx,
tasks_blocked: HashSet::new(),
tasks_runnable: Vec::new(),
tasks_done: HashMap::new(),
rdeps: HashMap::new(),
- base_args,
tpl: TemplateEngine::new(),
};
@@ -156,19 +138,13 @@ impl<'ctx> Executor<'ctx> {
.filter_map(|dep| self.tasks_done[&dep.task].output.get(dep.output))
.map(|&output| Dependency::Task {
output,
- path: paths::abs(paths::SYSROOT_PREFIX),
+ path: paths::abs(paths::TASK_SYSROOT),
}),
)
.map(|dep| (dep.dependency_hash(), dep))
.collect()
}
- fn eval_command(&self, task_def: &TaskDef, task_args: &TaskArgs) -> Result<String> {
- let mut args = task_args.clone();
- args.0.extend(self.base_args.0.clone());
- self.tpl.eval(&task_def, &args)
- }
-
fn run_one(&self, task_ref: &TaskRef<'ctx>, runner: &impl runner::Runner) -> Result<TaskMeta> {
let task_def = &self.ctx[task_ref.id];
let task_deps = self.task_deps(task_ref);
@@ -193,11 +169,9 @@ impl<'ctx> Executor<'ctx> {
})
.unwrap_or_default();
- let command = self
- .eval_command(&task_def, &task_ref.args)
- .with_context(|| {
- format!("Failed to evaluate command template for task {}", task_ref)
- })?;
+ let command = self.tpl.eval(&task_def, &task_ref.args).with_context(|| {
+ format!("Failed to evaluate command template for task {}", task_ref)
+ })?;
let input = runner::TaskInput {
command,