Auto merge of #12465 - Veykril:buildscripts, r=Veykril

internal: Only record build script outputs when the output has been changed

Follow up to https://github.com/rust-lang/rust-analyzer/pull/12457
This commit is contained in:
bors 2022-06-04 13:05:36 +00:00
commit 044b6ddca9

View File

@ -142,18 +142,18 @@ impl WorkspaceBuildScripts {
} }
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 @@ impl WorkspaceBuildScripts {
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,
); );