From 62fede212ac6c8f0cb8948ece79a237cfb18e095 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 4 Jun 2022 15:04:56 +0200 Subject: [PATCH] Only record build script outputs when the output has been changed --- crates/project-model/src/build_scripts.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/project-model/src/build_scripts.rs b/crates/project-model/src/build_scripts.rs index 73091306a85..ff46bb8fb43 100644 --- a/crates/project-model/src/build_scripts.rs +++ b/crates/project-model/src/build_scripts.rs @@ -142,18 +142,18 @@ pub(crate) fn run( } acc }; - let package_build_data = - outputs[package].get_or_insert_with(Default::default); // cargo_metadata crate returns default (empty) path for // older cargos, which is not absolute, so work around that. - if !message.out_dir.as_str().is_empty() { - let out_dir = - AbsPathBuf::assert(PathBuf::from(message.out_dir.into_os_string())); - package_build_data.out_dir = Some(out_dir); - package_build_data.cfgs = cfgs; + let out_dir = message.out_dir.into_os_string(); + if !out_dir.is_empty() { + let data = outputs[package].get_or_insert_with(Default::default); + let out_dir = Some(AbsPathBuf::assert(PathBuf::from(out_dir))); + (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) => { let package = match by_id.get(&message.package_id.repr) { @@ -195,7 +195,7 @@ pub(crate) fn run( for package in workspace.packages() { if let Some(package_build_data) = &mut outputs[package] { tracing::info!( - "{} BuildScriptOutput: {:?}", + "{}: {:?}", workspace[package].manifest.parent().display(), package_build_data, );