@@ -184,26 +184,7 @@ fn make_win_dist(
184184 return ;
185185 }
186186
187- //Ask gcc where it keeps its stuff
188- let mut cmd = command ( builder. cc ( target) ) ;
189- cmd. arg ( "-print-search-dirs" ) ;
190- let gcc_out = cmd. run_capture_stdout ( builder) . stdout ( ) ;
191-
192- let mut bin_path: Vec < _ > = env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) . collect ( ) ;
193- let mut lib_path = Vec :: new ( ) ;
194-
195- for line in gcc_out. lines ( ) {
196- let idx = line. find ( ':' ) . unwrap ( ) ;
197- let key = & line[ ..idx] ;
198- let trim_chars: & [ _ ] = & [ ' ' , '=' ] ;
199- let value = env:: split_paths ( line[ ( idx + 1 ) ..] . trim_start_matches ( trim_chars) ) ;
200-
201- if key == "programs" {
202- bin_path. extend ( value) ;
203- } else if key == "libraries" {
204- lib_path. extend ( value) ;
205- }
206- }
187+ let ( bin_path, lib_path) = get_cc_search_dirs ( target, builder) ;
207188
208189 let compiler = if target == "i686-pc-windows-gnu" {
209190 "i686-w64-mingw32-gcc.exe"
@@ -320,6 +301,34 @@ fn make_win_dist(
320301 }
321302}
322303
304+
305+ fn get_cc_search_dirs (
306+ target : TargetSelection ,
307+ builder : & Builder < ' _ > ,
308+ ) -> ( Vec < PathBuf > , Vec < PathBuf > ) {
309+ //Ask gcc where it keeps its stuff
310+ let mut cmd = command ( builder. cc ( target) ) ;
311+ cmd. arg ( "-print-search-dirs" ) ;
312+ let gcc_out = cmd. run_capture_stdout ( builder) . stdout ( ) ;
313+
314+ let mut bin_path: Vec < _ > = env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) . collect ( ) ;
315+ let mut lib_path = Vec :: new ( ) ;
316+
317+ for line in gcc_out. lines ( ) {
318+ let idx = line. find ( ':' ) . unwrap ( ) ;
319+ let key = & line[ ..idx] ;
320+ let trim_chars: & [ _ ] = & [ ' ' , '=' ] ;
321+ let value = env:: split_paths ( line[ ( idx + 1 ) ..] . trim_start_matches ( trim_chars) ) ;
322+
323+ if key == "programs" {
324+ bin_path. extend ( value) ;
325+ } else if key == "libraries" {
326+ lib_path. extend ( value) ;
327+ }
328+ }
329+ ( bin_path, lib_path)
330+ }
331+
323332#[ derive( Debug , PartialOrd , Ord , Clone , Hash , PartialEq , Eq ) ]
324333pub struct Mingw {
325334 pub host : TargetSelection ,
0 commit comments