@@ -614,19 +614,20 @@ impl Config {
614
614
}
615
615
616
616
let mut makeflags = None ;
617
- let mut parallel_args = Vec :: new ( ) ;
617
+ let mut parallel_flags = None ;
618
+
618
619
if let Ok ( s) = env:: var ( "NUM_JOBS" ) {
619
620
match self . generator . as_ref ( ) . map ( |g| g. to_string_lossy ( ) ) {
620
621
Some ( ref g) if g. contains ( "Ninja" ) => {
621
- parallel_args . push ( format ! ( "-j{}" , s) ) ;
622
+ parallel_flags = Some ( format ! ( "-j{}" , s) ) ;
622
623
}
623
624
Some ( ref g) if g. contains ( "Visual Studio" ) => {
624
- parallel_args . push ( format ! ( "/m:{}" , s) ) ;
625
+ parallel_flags = Some ( format ! ( "/m:{}" , s) ) ;
625
626
}
626
627
Some ( ref g) if g. contains ( "NMake" ) => {
627
628
// NMake creates `Makefile`s, but doesn't understand `-jN`.
628
629
}
629
- _ if fs:: metadata ( & dst . join ( "build/ Makefile" ) ) . is_ok ( ) => {
630
+ _ if fs:: metadata ( & build . join ( "Makefile" ) ) . is_ok ( ) => {
630
631
match env:: var_os ( "CARGO_MAKEFLAGS" ) {
631
632
// Only do this on non-windows and non-bsd
632
633
// On Windows, we could be invoking make instead of
@@ -641,7 +642,7 @@ impl Config {
641
642
) => makeflags = Some ( s. clone ( ) ) ,
642
643
643
644
// This looks like `make`, let's hope it understands `-jN`.
644
- _ => parallel_args . push ( format ! ( "-j{}" , s) ) ,
645
+ _ => makeflags = Some ( OsString :: from ( format ! ( "-j{}" , s) ) ) ,
645
646
}
646
647
}
647
648
_ => { }
@@ -654,18 +655,24 @@ impl Config {
654
655
for & ( ref k, ref v) in c_compiler. env ( ) . iter ( ) . chain ( & self . env ) {
655
656
cmd. env ( k, v) ;
656
657
}
658
+
657
659
if let Some ( flags) = makeflags {
658
660
cmd. env ( "MAKEFLAGS" , flags) ;
659
661
}
660
662
663
+ if let Some ( flags) = parallel_flags {
664
+ cmd. arg ( flags) ;
665
+ }
666
+
661
667
cmd. arg ( "--build" ) . arg ( "." ) ;
662
668
663
669
if !self . no_build_target {
664
670
cmd. arg ( "--target" ) . arg ( target) ;
665
671
}
672
+
666
673
cmd. arg ( "--config" ) . arg ( & profile)
667
- . arg ( "--" ) . args ( & self . build_args )
668
- . args ( & parallel_args )
674
+ . arg ( "--" )
675
+ . args ( & self . build_args )
669
676
. current_dir ( & build) ;
670
677
671
678
run ( & mut cmd, "cmake" ) ;
0 commit comments