Skip to content

Commit

Permalink
Swapping inputs/outputs and input_list/output_list
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbor committed Jul 5, 2024
1 parent fb16549 commit 069e7da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions examples/cproj/zinn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ constants:
OBJECTS: "{{re SOURCES '([^\\\\s ]*).c' (cat BUILDDIR '/' '$1.o')}}"
jobs:
builddir:
outputs: ["{{BUILDDIR}}"]
outputs: "{{BUILDDIR}}"
run: mkdir -vp {{BUILDDIR}}

object:
args: [path]
requires:
- job: builddir
inputs: ["{{path}}"]
outputs: ["{{BUILDDIR}}/{{subst path '.c' '.o'}}"]
inputs: "{{path}}"
outputs: "{{BUILDDIR}}/{{subst path '.c' '.o'}}"
run: |
echo "compiling."
sleep 1
Expand All @@ -32,8 +32,8 @@ jobs:
param: path
inputs: "{{SOURCES}}"
- job: builddir
input_list: "{{OBJECTS}}"
output_list: "{{BUILDDIR}}/{{BIN}}"
inputs: "{{OBJECTS}}"
outputs: "{{BUILDDIR}}/{{BIN}}"
run: |
echo "linking."
sleep 1
Expand Down
24 changes: 12 additions & 12 deletions src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ pub struct JobDescription {
args: Vec<String>,

#[serde(default)]
inputs: Vec<String>,
inputs: Option<String>,

#[serde(default)]
input_list: Option<String>,
input_list: Vec<String>,

#[serde(default)]
outputs: Vec<String>,
outputs: Option<String>,

#[serde(default)]
output_list: Option<String>,
output_list: Vec<String>,
}

/// Executable job with dependencies resolved and all variables applied
Expand Down Expand Up @@ -122,23 +122,23 @@ impl JobDescription {
}

let mut inputs = Vec::new();
for input in &self.inputs {
inputs.push(handlebars.render_template(input, &combined_vars)?);
}
if let Some(input_str) = &self.input_list {
if let Some(input_str) = &self.inputs {
let rendered_input_str = handlebars.render_template(input_str, &combined_vars)?;
let additional_inputs = rendered_input_str .split(char::is_whitespace).map(|s| s.to_owned());
inputs.extend(additional_inputs)
}
let mut outputs = Vec::new();
for output in &self.outputs {
outputs.push(handlebars.render_template(output, &combined_vars)?);
for input in &self.input_list {
inputs.push(handlebars.render_template(input, &combined_vars)?);
}
if let Some(output_str) = &self.output_list {
let mut outputs = Vec::new();
if let Some(output_str) = &self.outputs {
let rendered_output_str = handlebars.render_template(output_str, &combined_vars)?;
let additional_outputs = rendered_output_str .split(char::is_whitespace).map(|s| s.to_owned());
outputs.extend(additional_outputs)
}
for output in &self.output_list {
outputs.push(handlebars.render_template(output, &combined_vars)?);
}

let run = handlebars.render_template(&self.run, &combined_vars)?;
let name = name.replace('\n', "");
Expand Down

0 comments on commit 069e7da

Please sign in to comment.