|
17 | 17 |
|
18 | 18 | use std::env; |
19 | 19 | use std::path::PathBuf; |
20 | | -use std::process::Command; |
| 20 | +use std::process::{Child, Command}; |
21 | 21 | use std::str::FromStr; |
22 | 22 | use std::time::Instant; |
23 | 23 |
|
@@ -171,19 +171,8 @@ fn main() { |
171 | 171 | let is_test = args.iter().any(|a| a == "--test"); |
172 | 172 | // If the user requested resource usage data, then |
173 | 173 | // include that in addition to the timing output. |
174 | | - let rusage_data = env::var_os("RUSTC_PRINT_STEP_RUSAGE").and_then(|_| { |
175 | | - #[cfg(windows)] |
176 | | - { |
177 | | - use std::os::windows::io::AsRawHandle; |
178 | | - let handle = child.as_raw_handle(); |
179 | | - format_rusage_data(handle) |
180 | | - } |
181 | | - #[cfg(not(windows))] |
182 | | - { |
183 | | - let _child = child; |
184 | | - format_rusage_data() |
185 | | - } |
186 | | - }); |
| 174 | + let rusage_data = |
| 175 | + env::var_os("RUSTC_PRINT_STEP_RUSAGE").and_then(|_| format_rusage_data(child)); |
187 | 176 | eprintln!( |
188 | 177 | "[RUSTC-TIMING] {} test:{} {}.{:03}{}{}", |
189 | 178 | crate_name, |
@@ -221,15 +210,16 @@ fn main() { |
221 | 210 | } |
222 | 211 |
|
223 | 212 | #[cfg(all(not(unix), not(windows)))] |
224 | | -/// getrusage is not available on non-unix platforms. So for now, we do not |
225 | | -/// bother trying to make a shim for it. |
226 | | -fn format_rusage_data() -> Option<String> { |
| 213 | +// In the future we can add this for more platforms |
| 214 | +fn format_rusage_data(_child: Child) -> Option<String> { |
227 | 215 | None |
228 | 216 | } |
229 | 217 |
|
230 | 218 | #[cfg(windows)] |
231 | | -fn format_rusage_data(handle: std::os::windows::raw::HANDLE) -> Option<String> { |
| 219 | +fn format_rusage_data(child: Child) -> Option<String> { |
| 220 | + use std::os::windows::io::AsRawHandle; |
232 | 221 | use winapi::um::{processthreadsapi, psapi, timezoneapi}; |
| 222 | + let handle = child.as_raw_handle(); |
233 | 223 | macro_rules! try_bool { |
234 | 224 | ($e:expr) => { |
235 | 225 | if $e != 1 { |
@@ -295,7 +285,7 @@ fn format_rusage_data(handle: std::os::windows::raw::HANDLE) -> Option<String> { |
295 | 285 | /// fields. Note that we are focusing mainly on data that we believe to be |
296 | 286 | /// supplied on Linux (the `rusage` struct has other fields in it but they are |
297 | 287 | /// currently unsupported by Linux). |
298 | | -fn format_rusage_data() -> Option<String> { |
| 288 | +fn format_rusage_data(_child: Child) -> Option<String> { |
299 | 289 | let rusage: libc::rusage = unsafe { |
300 | 290 | let mut recv = std::mem::zeroed(); |
301 | 291 | // -1 is RUSAGE_CHILDREN, which means to get the rusage for all children |
|
0 commit comments