diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-09-25 13:02:31 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-09-25 13:02:31 +0200 |
commit | 07530f2233d24203d776b5b133060eda7572c101 (patch) | |
tree | 3d797b75e72c08d0a31abf38e5439d8f6d1f2151 | |
parent | dfa64adf02b0c046daaec60e508662c194ffb223 (diff) | |
download | rebel-07530f2233d24203d776b5b133060eda7572c101.tar rebel-07530f2233d24203d776b5b133060eda7572c101.zip |
task: move common parts of InheritDep and OutputDep into a separate struct
-rw-r--r-- | src/context.rs | 8 | ||||
-rw-r--r-- | src/task.rs | 17 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/context.rs b/src/context.rs index a07d8f1..77f1389 100644 --- a/src/context.rs +++ b/src/context.rs @@ -167,8 +167,8 @@ impl Context { } fn inherit_ref<'ctx>(&'ctx self, dep: &'ctx InheritDep, args: &TaskArgs) -> Result<TaskRef> { - let mapped_args = Context::map_args(&dep.task, &dep.args, args, false)?; - self.task_ref(&dep.task, mapped_args.as_ref()) + let mapped_args = Context::map_args(&dep.dep.task, &dep.dep.args, args, false)?; + self.task_ref(&dep.dep.task, mapped_args.as_ref()) } pub fn output_ref<'ctx>( @@ -177,9 +177,9 @@ impl Context { args: &TaskArgs, build_dep: bool, ) -> Result<OutputRef<'ctx>> { - let mapped_args = Context::map_args(&dep.task, &dep.args, args, build_dep)?; + let mapped_args = Context::map_args(&dep.dep.task, &dep.dep.args, args, build_dep)?; Ok(OutputRef { - task: self.task_ref(&dep.task, mapped_args.as_ref())?, + task: self.task_ref(&dep.dep.task, mapped_args.as_ref())?, output: &dep.output, }) } diff --git a/src/task.rs b/src/task.rs index 34972e6..1b9b6dc 100644 --- a/src/task.rs +++ b/src/task.rs @@ -8,6 +8,13 @@ use crate::{ }; #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)] +pub struct TaskDep { + pub task: TaskID, + #[serde(default)] + pub args: ArgMapping, +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)] pub struct Fetch { pub name: String, pub sha256: StringHash, @@ -19,16 +26,14 @@ fn default_output_name() -> String { #[derive(Clone, Debug, Deserialize)] pub struct InheritDep { - pub task: TaskID, - #[serde(default)] - pub args: ArgMapping, + #[serde(flatten)] + pub dep: TaskDep, } #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)] pub struct OutputDep { - pub task: TaskID, - #[serde(default)] - pub args: ArgMapping, + #[serde(flatten)] + pub dep: TaskDep, #[serde(default = "default_output_name")] pub output: String, } |