@@ -481,13 +481,15 @@ impl<'a> WorkInfo<'a> {
481
481
// we need the build plan to find our build artifacts
482
482
opts. build_config . build_plan = true ;
483
483
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
+ } ;
491
493
492
494
if let Some ( s) = matches. opt_str ( "features" ) {
493
495
opts. features = s. split ( ' ' ) . map ( str:: to_owned) . collect ( ) ;
@@ -512,11 +514,14 @@ impl<'a> WorkInfo<'a> {
512
514
513
515
// redirection gang
514
516
let outfile = File :: create ( & outdir) ?;
515
- let old_stdio = std:: io:: set_print ( Some ( Box :: new ( outfile) ) ) ;
516
517
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) ;
518
521
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) ;
520
525
521
526
// actually compile things now
522
527
opts. build_config . build_plan = false ;
@@ -530,7 +535,9 @@ impl<'a> WorkInfo<'a> {
530
535
for i in & build_plan. invocations {
531
536
if let Some ( kind) = i. target_kind . get ( 0 ) {
532
537
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 ( ) ) ) ;
534
541
}
535
542
}
536
543
}
0 commit comments