diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-11-16 20:52:34 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-11-16 20:52:34 +0100 |
commit | 1ad4750948ab49900b1b6ff5b455c11ebe7470eb (patch) | |
tree | d72737a8e045dbadb734425d687f2a09f0c7453b | |
parent | bd8479a1ebf3862c13909e270ddd6179d9a24591 (diff) | |
download | rebel-1ad4750948ab49900b1b6ff5b455c11ebe7470eb.tar rebel-1ad4750948ab49900b1b6ff5b455c11ebe7470eb.zip |
driver: pass set of tasks to force-run to driver instance
-rw-r--r-- | crates/driver/src/context.rs | 14 | ||||
-rw-r--r-- | crates/driver/src/driver.rs | 6 | ||||
-rw-r--r-- | crates/driver/src/main.rs | 10 |
3 files changed, 22 insertions, 8 deletions
diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs index 3a40102..2f29aed 100644 --- a/crates/driver/src/context.rs +++ b/crates/driver/src/context.rs @@ -17,7 +17,8 @@ use common::{ use crate::{ args::*, - parse, paths, + parse::{self, TaskFlags}, + paths, pin::{self, Pins}, task::*, }; @@ -353,8 +354,8 @@ impl Context { }) } - pub fn parse<'ctx>(&'ctx self, s: &str) -> error::Result<TaskRef> { - let (parsed, _flags) = parse::parse_task_with_flags(s).context("Invalid task syntax")?; + pub fn parse<'ctx>(&'ctx self, s: &str) -> error::Result<(TaskRef, TaskFlags)> { + let (parsed, flags) = parse::parse_task_with_flags(s).context("Invalid task syntax")?; let recipe = parsed.recipe.to_string(); let task = parsed.task.to_string(); @@ -383,8 +384,11 @@ impl Context { args.set("target", Some(plat)); } - self.task_ref(ctx_id, &args) - .with_context(|| format!("Failed to instantiate task {}", id)) + let task_ref = self + .task_ref(ctx_id, &args) + .with_context(|| format!("Failed to instantiate task {}", id))?; + + Ok((task_ref, flags)) } fn map_args<'ctx, 'args>( diff --git a/crates/driver/src/driver.rs b/crates/driver/src/driver.rs index ebbdb36..43820a2 100644 --- a/crates/driver/src/driver.rs +++ b/crates/driver/src/driver.rs @@ -155,7 +155,11 @@ pub struct Driver<'ctx> { } impl<'ctx> Driver<'ctx> { - pub fn new(ctx: &'ctx Context, taskset: HashSet<TaskRef<'ctx>>) -> Result<Self> { + pub fn new( + ctx: &'ctx Context, + taskset: HashSet<TaskRef<'ctx>>, + _force_run: HashSet<TaskRef<'ctx>>, + ) -> Result<Self> { let mut driver = Driver { rdeps: Default::default(), tasks_blocked: Default::default(), diff --git a/crates/driver/src/main.rs b/crates/driver/src/main.rs index 0e5c629..ea97ee5 100644 --- a/crates/driver/src/main.rs +++ b/crates/driver/src/main.rs @@ -9,6 +9,8 @@ mod resolve; mod task; mod template; +use std::collections::HashSet; + use clap::Parser; use runner::Runner; @@ -37,9 +39,10 @@ fn main() { .unwrap(); let mut rsv = resolve::Resolver::new(&ctx); + let mut force_run = HashSet::new(); for task in opts.tasks { - let task_ref = match ctx.parse(&task) { + let (task_ref, flags) = match ctx.parse(&task) { Ok(task_ref) => task_ref, Err(err) => { eprintln!("{}", err); @@ -53,9 +56,12 @@ fn main() { } std::process::exit(1); } + if flags.force_run { + force_run.insert(task_ref); + } } let taskset = rsv.into_taskset(); - let mut driver = driver::Driver::new(&ctx, taskset).unwrap(); + let mut driver = driver::Driver::new(&ctx, taskset, force_run).unwrap(); if let Err(error) = driver.run(&runner) { eprintln!("{}", error); std::process::exit(1); |