diff options
Diffstat (limited to 'crates/executor/src/task.rs')
-rw-r--r-- | crates/executor/src/task.rs | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/crates/executor/src/task.rs b/crates/executor/src/task.rs new file mode 100644 index 0000000..fe9572c --- /dev/null +++ b/crates/executor/src/task.rs @@ -0,0 +1,84 @@ +use std::collections::{HashMap, HashSet}; + +use serde::Deserialize; + +use common::{string_hash::StringHash, types::TaskID}; + +use crate::{ + args::{ArgMapping, ArgType}, + recipe, +}; + +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash, Default)] +pub struct RecipeMeta { + #[serde(default)] + pub name: String, + pub version: Option<String>, +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)] +pub struct TaskDep { + #[serde(flatten, deserialize_with = "recipe::deserialize_task_id")] + pub id: TaskID, + #[serde(default)] + pub args: ArgMapping, +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)] +pub struct Fetch { + pub name: String, + pub sha256: StringHash, +} + +fn default_output_name() -> String { + "default".to_string() +} + +#[derive(Clone, Debug, Deserialize)] +pub struct InheritDep { + #[serde(flatten)] + pub dep: TaskDep, +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)] +pub struct OutputDep { + #[serde(flatten)] + pub dep: TaskDep, + #[serde(default)] + pub noinherit: bool, + #[serde(default = "default_output_name")] + pub output: String, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct Output { + pub path: Option<String>, + #[serde(default)] + pub runtime_depends: HashSet<OutputDep>, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct Action { + #[serde(default)] + pub run: String, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct TaskDef { + #[serde(skip)] + pub meta: RecipeMeta, + #[serde(default)] + pub args: HashMap<String, ArgType>, + #[serde(default)] + pub inherit: Option<InheritDep>, + #[serde(default)] + pub fetch: HashSet<Fetch>, + #[serde(default)] + pub build_depends: HashSet<OutputDep>, + #[serde(default)] + pub depends: HashSet<OutputDep>, + #[serde(default)] + pub output: HashMap<String, Output>, + #[serde(flatten)] + pub action: Action, +} |