Only record build script outputs when the output has been changed

This commit is contained in:
Lukas Wirth 2022-06-04 15:04:56 +02:00
parent 312913a640
commit 62fede212a

View File

@ -142,18 +142,18 @@ pub(crate) fn run(
} }
acc acc
}; };
let package_build_data =
outputs[package].get_or_insert_with(Default::default);
// cargo_metadata crate returns default (empty) path for // cargo_metadata crate returns default (empty) path for
// older cargos, which is not absolute, so work around that. // older cargos, which is not absolute, so work around that.
if !message.out_dir.as_str().is_empty() { let out_dir = message.out_dir.into_os_string();
let out_dir = if !out_dir.is_empty() {
AbsPathBuf::assert(PathBuf::from(message.out_dir.into_os_string())); let data = outputs[package].get_or_insert_with(Default::default);
package_build_data.out_dir = Some(out_dir); let out_dir = Some(AbsPathBuf::assert(PathBuf::from(out_dir)));
package_build_data.cfgs = cfgs; (data.out_dir, data.cfgs) = (out_dir, cfgs);
}
if !message.env.is_empty() {
outputs[package].get_or_insert_with(Default::default).envs =
message.env;
} }
package_build_data.envs = message.env;
} }
Message::CompilerArtifact(message) => { Message::CompilerArtifact(message) => {
let package = match by_id.get(&message.package_id.repr) { let package = match by_id.get(&message.package_id.repr) {
@ -195,7 +195,7 @@ pub(crate) fn run(
for package in workspace.packages() { for package in workspace.packages() {
if let Some(package_build_data) = &mut outputs[package] { if let Some(package_build_data) = &mut outputs[package] {
tracing::info!( tracing::info!(
"{} BuildScriptOutput: {:?}", "{}: {:?}",
workspace[package].manifest.parent().display(), workspace[package].manifest.parent().display(),
package_build_data, package_build_data,
); );