@@ -481,13 +481,15 @@ impl<'a> WorkInfo<'a> {
481481 // we need the build plan to find our build artifacts
482482 opts. build_config . build_plan = true ;
483483
484- if let Some ( target) = matches. opt_str ( "target" ) {
485- let target = cargo:: core:: compiler:: CompileTarget :: new ( & target) ;
486- if let Ok ( target) = target {
487- let kind = cargo:: core:: compiler:: CompileKind :: Target ( target) ;
488- opts. build_config . requested_kind = kind;
489- }
490- }
484+ let compile_kind = if let Some ( target) = matches. opt_str ( "target" ) {
485+ let target = cargo:: core:: compiler:: CompileTarget :: new ( & target) ?;
486+
487+ let kind = cargo:: core:: compiler:: CompileKind :: Target ( target) ;
488+ opts. build_config . requested_kinds = vec ! [ kind] ;
489+ kind
490+ } else {
491+ cargo:: core:: compiler:: CompileKind :: Host
492+ } ;
491493
492494 if let Some ( s) = matches. opt_str ( "features" ) {
493495 opts. features = s. split ( ' ' ) . map ( str:: to_owned) . collect ( ) ;
@@ -512,11 +514,14 @@ impl<'a> WorkInfo<'a> {
512514
513515 // redirection gang
514516 let outfile = File :: create ( & outdir) ?;
515- let old_stdio = std:: io:: set_print ( Some ( Box :: new ( outfile) ) ) ;
516517
517- let _ = cargo:: ops:: compile ( & self . workspace , & opts) ?;
518+ let mut file_write = cargo:: core:: Shell :: from_write ( Box :: new ( outfile) ) ;
519+ file_write. set_verbosity ( cargo:: core:: Verbosity :: Quiet ) ;
520+ let old_shell = std:: mem:: replace ( & mut * config. shell ( ) , file_write) ;
518521
519- std:: io:: set_print ( old_stdio) ;
522+ cargo:: ops:: compile ( & self . workspace , & opts) ?;
523+
524+ let _ = std:: mem:: replace ( & mut * config. shell ( ) , old_shell) ;
520525
521526 // actually compile things now
522527 opts. build_config . build_plan = false ;
@@ -530,7 +535,9 @@ impl<'a> WorkInfo<'a> {
530535 for i in & build_plan. invocations {
531536 if let Some ( kind) = i. target_kind . get ( 0 ) {
532537 if kind. contains ( "lib" ) && i. package_name == name {
533- return Ok ( ( i. outputs [ 0 ] . clone ( ) , compilation. deps_output ) ) ;
538+ let deps_output = & compilation. deps_output [ & compile_kind] ;
539+
540+ return Ok ( ( i. outputs [ 0 ] . clone ( ) , deps_output. clone ( ) ) ) ;
534541 }
535542 }
536543 }
0 commit comments