Skip to content

Commit edc139b

Browse files
BusyJaythomcc
authored andcommitted
use jobserver if available
passing --parallel to cmake will execute make with `-jN` hence jobserver is ignored. Signed-off-by: Jay Lee <[email protected]>
1 parent cfe11fc commit edc139b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ impl Config {
830830
}
831831

832832
// If the generated project is Makefile based we should carefully transfer corresponding CARGO_MAKEFLAGS
833+
let mut use_jobserver = false;
833834
if fs::metadata(&build.join("Makefile")).is_ok() {
834835
match env::var_os("CARGO_MAKEFLAGS") {
835836
// Only do this on non-windows and non-bsd
@@ -844,6 +845,7 @@ impl Config {
844845
|| cfg!(target_os = "bitrig")
845846
|| cfg!(target_os = "dragonflybsd")) =>
846847
{
848+
use_jobserver = true;
847849
cmd.env("MAKEFLAGS", makeflags);
848850
}
849851
_ => {}
@@ -864,7 +866,7 @@ impl Config {
864866

865867
// --parallel requires CMake 3.12:
866868
// https://cmake.org/cmake/help/latest/release/3.12.html#command-line
867-
if version >= Version::new(3, 12) {
869+
if version >= Version::new(3, 12) && !use_jobserver {
868870
if let Ok(s) = env::var("NUM_JOBS") {
869871
// See https://cmake.org/cmake/help/v3.12/manual/cmake.1.html#build-tool-mode
870872
cmd.arg("--parallel").arg(s);

0 commit comments

Comments
 (0)