Skip to content

Commit 8c11170

Browse files
committed
Changes parallel_flags to be an Option<OsString>
1 parent 1e15ffa commit 8c11170

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/lib.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -614,19 +614,20 @@ impl Config {
614614
}
615615

616616
let mut makeflags = None;
617-
let mut parallel_args = Vec::new();
617+
let mut parallel_flags = None;
618+
618619
if let Ok(s) = env::var("NUM_JOBS") {
619620
match self.generator.as_ref().map(|g| g.to_string_lossy()) {
620621
Some(ref g) if g.contains("Ninja") => {
621-
parallel_args.push(format!("-j{}", s));
622+
parallel_flags = Some(format!("-j{}", s));
622623
}
623624
Some(ref g) if g.contains("Visual Studio") => {
624-
parallel_args.push(format!("/m:{}", s));
625+
parallel_flags = Some(format!("/m:{}", s));
625626
}
626627
Some(ref g) if g.contains("NMake") => {
627628
// NMake creates `Makefile`s, but doesn't understand `-jN`.
628629
}
629-
_ if fs::metadata(&dst.join("build/Makefile")).is_ok() => {
630+
_ if fs::metadata(&build.join("Makefile")).is_ok() => {
630631
match env::var_os("CARGO_MAKEFLAGS") {
631632
// Only do this on non-windows and non-bsd
632633
// On Windows, we could be invoking make instead of
@@ -641,7 +642,7 @@ impl Config {
641642
) => makeflags = Some(s.clone()),
642643

643644
// 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))),
645646
}
646647
}
647648
_ => {}
@@ -654,18 +655,24 @@ impl Config {
654655
for &(ref k, ref v) in c_compiler.env().iter().chain(&self.env) {
655656
cmd.env(k, v);
656657
}
658+
657659
if let Some(flags) = makeflags {
658660
cmd.env("MAKEFLAGS", flags);
659661
}
660662

663+
if let Some(flags) = parallel_flags {
664+
cmd.arg(flags);
665+
}
666+
661667
cmd.arg("--build").arg(".");
662668

663669
if !self.no_build_target {
664670
cmd.arg("--target").arg(target);
665671
}
672+
666673
cmd.arg("--config").arg(&profile)
667-
.arg("--").args(&self.build_args)
668-
.args(&parallel_args)
674+
.arg("--")
675+
.args(&self.build_args)
669676
.current_dir(&build);
670677

671678
run(&mut cmd, "cmake");

0 commit comments

Comments
 (0)