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
};
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,
);