Skip to content
Myr

Clean up dep-info files from OUT_DIR

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent a0b868a · Browse files · 1 file+24 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−2 removed

  • other:+24 added−2 removed

1 file+24 added−2 removed

modified:build.rs+24 added-2 removed
1use std::env;2use std::ffi::OsString;3use std::fs;4use std::io::ErrorKind;5use std::iter;6use std::path::Path;7use std::process::{self, Command, Stdio};8use std::str;
117 unmodified lines
126 }127128 let rustc = cargo_env_var("RUSTC");129 let out_dir = cargo_env_var("OUT_DIR");130 let out_subdir = Path::new(&out_dir).join("probe");131 let probefile = Path::new("build").join("probe.rs");132133 if let Err(err) = fs::create_dir(&out_subdir) {134 if err.kind() != ErrorKind::AlreadyExists {135 eprintln!("Failed to create {}: {}", out_subdir.display(), err);136 process::exit(1);137 }138 }139140 let rustc_wrapper = env::var_os("RUSTC_WRAPPER").filter(|wrapper| !wrapper.is_empty());141 let rustc_workspace_wrapper =142 env::var_os("RUSTC_WORKSPACE_WRAPPER").filter(|wrapper| !wrapper.is_empty());143 let mut rustc = rustc_wrapper
13 unmodified lines
157 .arg("--crate-type=lib")158 .arg("--emit=dep-info,metadata")159 .arg("--cap-lints=allow")160 .arg("--out-dir")151 .arg(out_dir)161 .arg(&out_subdir)162 .arg(probefile);163164 if let Some(target) = env::var_os("TARGET") {165 cmd.arg("--target").arg(target);
7 unmodified lines
173 }174 }175 }176167 match cmd.status() {177 let success = match cmd.status() {178 Ok(status) => status.success(),179 Err(_) => false,180 };181182 // Clean up to avoid leaving nondeterministic absolute paths in the dep-info183 // file in OUT_DIR, which causes nonreproducible builds in build systems184 // that treat the entire OUT_DIR as an artifact.185 if let Err(err) = fs::remove_dir_all(&out_subdir) {186 if err.kind() != ErrorKind::NotFound {187 eprintln!("Failed to clean up {}: {}", out_subdir.display(), err);188 process::exit(1);189 }190 }191192 success193}194195fn rustc_minor_version() -> Option<u32> {196 let rustc = cargo_env_var("RUSTC");
18 unmodified lines