1use crate::command::SerializedHash;
2use crate::environment::{ReadWriteEnvironment, ReadWriteEnvironmentVec};
3use crate::node::Node;
4use lazy_static::lazy_static;
5use regex::Regex;
6use std::fmt::{Display, Formatter};
7use std::sync::{Arc, Mutex};
8
9mod lua_binding;
10mod run;
11mod serialization;
12
13lazy_static! {
14 pub(crate) static ref SPLIT_RE: Regex = Regex::new(r"\s+").unwrap();
15 pub(crate) static ref ENV_RE: Regex =
16 Regex::new(r"\$\{([^:\.}\[]+:)?([^:\[\.}]+)(\[(\d+)])?\}").unwrap();
17}
18
19pub(crate) struct Task {
20 pub(crate) driver: String,
21 pub(crate) generator: String,
22 pub(crate) group: String,
23 pub(crate) env: Arc<Mutex<ReadWriteEnvironment>>,
24 pub(crate) inputs: Vec<Node>,
25 pub(crate) outputs: Vec<Node>,
26 pub(crate) predecessors: Vec<usize>,
27 pub(crate) successors: Vec<usize>,
28 pub(crate) signature: SerializedHash,
29}
30
31pub(crate) struct TaskHandle(pub(crate) usize);
32
33pub(crate) struct TaskSeed<'a>(pub &'a ReadWriteEnvironmentVec);
34
35impl Display for Task {
36 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
37 write!(f, "[{}/{}] {} ", self.group, self.generator, self.driver)?;
38 for (index, path) in self.inputs.iter().enumerate() {
39 if index != 0 {
40 write!(f, ", ")?;
41 }
42 write!(f, "{}", path)?;
43 }
44 write!(f, " -> ")?;
45 for (index, path) in self.outputs.iter().enumerate() {
46 if index != 0 {
47 write!(f, ", ")?;
48 }
49 write!(f, "{}", path)?;
50 }
51 Ok(())
52 }
53}