Commit fa218b0a

fa218b0ae62cMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

Merge pull request #343 from ryanseys/pr/default-jobs

chore(test): default -j to logical CPU count when no -j was passed

Details

Commit
fa218b0ae62c
Parent
a0e14abe8ff5
Merge parent
9e9f4c056a8b

MakefilemodifiedView file

@@ -62,6 +62,19 @@
6262 TIMEOUT10 := $(if $(TIMEOUT_BIN),$(TIMEOUT_BIN) 10,)
6363 TIMEOUT60 := $(if $(TIMEOUT_BIN),$(TIMEOUT_BIN) 60,)
6464
65+# Default -j to logical CPU count when MAKEFLAGS doesn't already
66+# carry a -j flag. The combined guard catches the three forms a user
67+# can supply -j in (per the GNU Make manual): `-j N` / `-jN` via
68+# filter, the short-flag-cluster form like `-kj` via findstring on
69+# the first word (the leading `-` makes firstword non-empty when
70+# MAKEFLAGS starts blank), and Make 4.x's `--jobserver-auth=…` long
71+# form. Note: GNU Make 3.81 (macOS system make) reports MAKEFLAGS
72+# as empty at parse time, so the guard always fires there; users on
73+# 3.81 wanting to override should pass `MAKEFLAGS=-jN make …`.
74+ifeq (,$(filter -j%,$(MAKEFLAGS))$(findstring j,$(firstword -$(MAKEFLAGS)))$(filter --jobserver%,$(MAKEFLAGS)))
75+ MAKEFLAGS += -j$(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)
76+endif
77+
6578 # Reference Ruby for `make test` / `make bench` output comparison.
6679 # Defaults to `ruby` (the system CRuby), matching the historical
6780 # behaviour. Override on the command line when a newer or differently-