Bug 815219 - Part 1: Automatically build using all available processor cores; r=ted
authorGregory Szorc <gps@mozilla.com>
Tue, 27 Nov 2012 14:01:17 -0800
changeset 114294 ba730945bc6db5a3aba668aebcd53dd3d3525a49
parent 114293 59281806d3a6505bcae91f58eeec9e46e5254589
child 114295 7f5e2a9addff52b23525e69ae41950d38b5b69f4
push id1219
push userjwalker@mozilla.com
push dateThu, 29 Nov 2012 23:24:42 +0000
treeherderfx-team@85471409cbfb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs815219
milestone20.0a1
Bug 815219 - Part 1: Automatically build using all available processor cores; r=ted
client.mk
--- a/client.mk
+++ b/client.mk
@@ -103,16 +103,24 @@ define CR
 
 endef
 
 # As $(shell) doesn't preserve newlines, use sed to replace them with an
 # unlikely sequence (||), which is then replaced back to newlines by make
 # before evaluation.
 $(eval $(subst ||,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/')))
 
+
+# Automatically add -jN to make flags if not defined. N defaults to number of cores.
+ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS)))
+  cores=$(shell $(PYTHON) -c 'import multiprocessing; print(multiprocessing.cpu_count())')
+  MOZ_MAKE_FLAGS += -j$(cores)
+endif
+
+
 ifndef MOZ_OBJDIR
   MOZ_OBJDIR = obj-$(CONFIG_GUESS)
 else
 # On Windows Pymake builds check MOZ_OBJDIR doesn't start with "/"
   ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
   ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR))))
   $(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.)
   endif