@@ -29,7 +29,7 @@ use std::collections::{HashMap, HashSet};
2929use std:: ffi:: { OsStr , OsString } ;
3030use std:: io:: { self , BufWriter , Read , Write } ;
3131use std:: path:: { Path , PathBuf } ;
32- use std:: process:: { self , Stdio } ;
32+ use std:: process;
3333
3434use crate :: errors:: * ;
3535
@@ -201,13 +201,9 @@ where
201201 if is_clang {
202202 cmd. arg ( "--driver-mode=cl" ) ;
203203 }
204- cmd. args ( & [ "-nologo" , "-showIncludes" , "-c" , "-Fonul" , "-I." ] )
204+ cmd. args ( & [ "-nologo" , "-showIncludes" , "-c" , "-Fonul" , "-I." , "-E" ] )
205205 . arg ( & input)
206- . current_dir ( tempdir. path ( ) )
207- // The MSDN docs say the -showIncludes output goes to stderr,
208- // but that's not true unless running with -E.
209- . stdout ( Stdio :: piped ( ) )
210- . stderr ( Stdio :: null ( ) ) ;
206+ . current_dir ( tempdir. path ( ) ) ;
211207 for ( k, v) in env {
212208 cmd. env ( k, v) ;
213209 }
@@ -216,16 +212,20 @@ where
216212 let output = run_input_output ( cmd, None ) . await ?;
217213
218214 if !output. status . success ( ) {
219- bail ! ( "Failed to detect showIncludes prefix" )
215+ warn ! (
216+ "Failed to detect showIncludes prefix (status: {:?})" ,
217+ output. status. code( ) . unwrap_or( -1 )
218+ )
220219 }
221220
222221 let process:: Output {
223- stdout : stdout_bytes ,
222+ stderr : stderr_bytes ,
224223 ..
225224 } = output;
226- let stdout = from_local_codepage ( & stdout_bytes)
227- . context ( "Failed to convert compiler stdout while detecting showIncludes prefix" ) ?;
228- for line in stdout. lines ( ) {
225+ let output = from_local_codepage ( & stderr_bytes)
226+ . context ( "Failed to convert compiler stderr while detecting showIncludes prefix" ) ?;
227+
228+ for line in output. lines ( ) {
229229 if !line. ends_with ( "test.h" ) {
230230 continue ;
231231 }
@@ -246,7 +246,7 @@ where
246246
247247 debug ! (
248248 "failed to detect showIncludes prefix with output: {}" ,
249- stdout
249+ output
250250 ) ;
251251
252252 bail ! ( "Failed to detect showIncludes prefix" )
@@ -1416,8 +1416,8 @@ mod test {
14161416 if s. starts_with ( "\\ \\ ?\\ " ) {
14171417 s = & s[ 4 ..] ;
14181418 }
1419- let stdout = format ! ( "blah: {}\r \n " , s) ;
1420- let stderr = String :: from ( "some\r \n stderr \r \n " ) ;
1419+ let stderr = format ! ( "blah: {}\r \n " , s) ;
1420+ let stdout = String :: from ( "some\r \n stdout \r \n " ) ;
14211421 next_command ( & creator, Ok ( MockChild :: new ( exit_status ( 0 ) , stdout, stderr) ) ) ;
14221422 assert_eq ! (
14231423 "blah: " ,
0 commit comments