Pile all the checksum info into a comment that goes in the same order as the file list for the makefile

This commit is contained in:
Jacob Kiesel 2024-09-28 18:09:44 -06:00
parent 081661b78d
commit dba814a922

View File

@ -536,7 +536,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
let write_deps_to_file = |file: &mut dyn Write| -> io::Result<()> {
for path in out_filenames {
writeln!(
write!(
file,
"{}: {}\n",
path.display(),
@ -546,6 +546,25 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
.intersperse(" ")
.collect::<String>()
)?;
// If caller requested this information, add special comments about source file checksums.
// These are not necessarily the same checksums as was used in the debug files.
if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() {
assert!(
files.iter().all(|(_path, _file_len, hash_algo)| hash_algo.is_some()),
"all files must have a checksum hash computed to output checksum hashes"
);
write!(file, " # ")?;
files
.iter()
.filter_map(|(_path, file_len, hash_algo)| {
hash_algo.map(|hash_algo| (path, file_len, hash_algo))
})
.try_for_each(|(_path, file_len, checksum_hash)| {
write!(file, "checksum:{checksum_hash} file_len:{file_len}, ")
})?;
}
writeln!(file)?;
}
// Emit a fake target for each input file to the compilation. This
@ -575,18 +594,6 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
}
}
// If caller requested this information, add special comments about source file checksums.
// These are not necessarily the same checksums as was used in the debug files.
if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() {
for (path, file_len, checksum_hash) in
files.iter().filter_map(|(path, file_len, hash_algo)| {
hash_algo.map(|hash_algo| (path, file_len, hash_algo))
})
{
writeln!(file, "# checksum:{checksum_hash} file_len:{file_len} {path}")?;
}
}
Ok(())
};