Skip to content

Commit 0027188

Browse files
committed
fixup! cargo build - dep file chain
1 parent b41972a commit 0027188

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

core/embed/xbuild/src/dep_tracking.rs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -206,34 +206,24 @@ fn dep_file_path(output: impl AsRef<Path>) -> PathBuf {
206206
PathBuf::from(dep_path)
207207
}
208208

209+
fn path_to_string(path: impl AsRef<Path>) -> String {
210+
path.as_ref().to_string_lossy().into_owned()
211+
}
212+
209213
fn dep_file_contents(
210214
inputs: &[impl AsRef<Path>],
211215
outputs: &[impl AsRef<Path>],
212216
args: Option<&str>,
213217
) -> String {
214-
let mut dep = String::new();
215-
dep.push_str("--args--\n");
216-
217-
if let Some(args) = args {
218-
dep.push_str(args);
219-
if !dep.ends_with('\n') {
220-
dep.push('\n');
221-
}
222-
}
223-
224-
dep.push_str("--inputs--\n");
225-
for input in inputs {
226-
dep.push_str(&input.as_ref().to_string_lossy());
227-
dep.push('\n');
228-
}
229-
230-
dep.push_str("--outputs--\n");
231-
for output in outputs {
232-
dep.push_str(&output.as_ref().to_string_lossy());
233-
dep.push('\n');
234-
}
235-
236-
dep
218+
std::iter::once("--args--".to_owned())
219+
.chain(args.into_iter().flat_map(str::lines).map(str::to_owned))
220+
.chain(std::iter::once("--inputs--".to_owned()))
221+
.chain(inputs.iter().map(path_to_string))
222+
.chain(std::iter::once("--outputs--".to_owned()))
223+
.chain(outputs.iter().map(path_to_string))
224+
.chain(std::iter::once(String::new()))
225+
.collect::<Vec<_>>()
226+
.join("\n")
237227
}
238228

239229
/// Converts a Command name and its arguments to a string representation for

0 commit comments

Comments
 (0)