|
8 | 8 | //! very new but replaces the manually implemented `BoolExt` trait. |
9 | 9 |
|
10 | 10 | use std::ffi::OsString; |
11 | | -#[cfg(feature = "debug-probe")] |
12 | | -use std::fmt; |
13 | | -#[cfg(feature = "debug-probe")] |
14 | | -use std::fmt::Write; |
15 | 11 | use std::fs; |
16 | 12 | use std::io::ErrorKind; |
17 | 13 | use std::path::Path; |
@@ -127,30 +123,11 @@ fn compile_probe(rustc_bootstrap: bool) -> bool { |
127 | 123 | } |
128 | 124 | } |
129 | 125 |
|
130 | | - #[cfg(feature = "debug-probe")] |
131 | | - let debug = rustc_probe_debug(); |
132 | | - #[cfg(feature = "debug-probe")] |
133 | | - if debug { |
134 | | - let mut msg = String::new(); |
135 | | - write_command(&mut msg, &cmd).expect("write to string does not fail"); |
136 | | - std::fs::write(out_subdir.join("probe-command"), msg) |
137 | | - .unwrap_or_else(|err| die!("failed to write probe command: {err}")); |
138 | | - } |
139 | | - |
140 | 126 | let success = match cmd.status() { |
141 | 127 | Ok(status) => status.success(), |
142 | 128 | Err(_) => false, |
143 | 129 | }; |
144 | 130 |
|
145 | | - // Clean up to avoid leaving nondeterministic absolute paths in the dep-info |
146 | | - // file in OUT_DIR, which causes nonreproducible builds in build systems |
147 | | - // that treat the entire OUT_DIR as an artifact. |
148 | | - #[cfg(feature = "debug-probe")] |
149 | | - if !debug { |
150 | | - rmrf(&out_subdir); |
151 | | - } |
152 | | - |
153 | | - #[cfg(not(feature = "debug-probe"))] |
154 | 131 | rmrf(&out_subdir); |
155 | 132 |
|
156 | 133 | success |
@@ -205,67 +182,3 @@ fn rustc_command() -> Command { |
205 | 182 | Command::new(path) |
206 | 183 | } |
207 | 184 | } |
208 | | - |
209 | | -#[cfg(feature = "debug-probe")] |
210 | | -fn rustc_probe_debug() -> bool { |
211 | | - fn is_falsy(mut s: OsString) -> bool { |
212 | | - if s.len() <= 5 { |
213 | | - s.make_ascii_lowercase(); |
214 | | - s.is_empty() || s == "0" || s == "false" || s == "no" || s == "off" |
215 | | - } else { |
216 | | - // otherwise it's too long to be a falsy value and a waste to lowercase |
217 | | - false |
218 | | - } |
219 | | - } |
220 | | - |
221 | | - println!("cargo:rerun-if-env-changed=RUSTC_PROBE_KEEP_PROBE"); |
222 | | - match std::env::var_os("RUSTC_PROBE_KEEP_PROBE") { |
223 | | - Some(v) => !is_falsy(v), |
224 | | - None => false, |
225 | | - } |
226 | | -} |
227 | | - |
228 | | -#[cfg(feature = "debug-probe")] |
229 | | -fn write_command(out: &mut impl Write, cmd: &Command) -> fmt::Result { |
230 | | - writeln!(out, "Running RUSTC command:")?; |
231 | | - if let Some(cwd) = cmd.get_current_dir() { |
232 | | - writeln!(out, " cwd : {}", cwd.display())?; |
233 | | - } else if let Ok(cwd) = std::env::current_dir() { |
234 | | - writeln!(out, " cwd : {}", cwd.display())?; |
235 | | - } else { |
236 | | - writeln!(out, " cwd : <unknown>")?; |
237 | | - } |
238 | | - |
239 | | - writeln!(out, " prog: {}", cmd.get_program().display())?; |
240 | | - |
241 | | - let mut args = cmd.get_args(); |
242 | | - if let Some(arg) = args.next() { |
243 | | - writeln!(out, " args: - {}", arg.display())?; |
244 | | - for arg in args { |
245 | | - writeln!(out, " - {}", arg.display())?; |
246 | | - } |
247 | | - } else { |
248 | | - writeln!(out, " args: <none>")?; |
249 | | - } |
250 | | - |
251 | | - let mut envs = cmd.get_envs(); |
252 | | - if let Some((env, opt)) = envs.next() { |
253 | | - if let Some(value) = opt { |
254 | | - writeln!(out, " env : {}={}", env.display(), value.display())?; |
255 | | - } else { |
256 | | - writeln!(out, " env : {}=<removed>", env.display())?; |
257 | | - } |
258 | | - |
259 | | - for (env, opt) in envs { |
260 | | - if let Some(value) = opt { |
261 | | - writeln!(out, " {}={}", env.display(), value.display())?; |
262 | | - } else { |
263 | | - writeln!(out, " {}=<removed>", env.display())?; |
264 | | - } |
265 | | - } |
266 | | - } else { |
267 | | - writeln!(out, " env : <none>")?; |
268 | | - } |
269 | | - |
270 | | - Ok(()) |
271 | | -} |
0 commit comments