summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathew Robinson <chasinglogic@gmail.com>2019-01-08 14:34:52 -0500
committerMathew Robinson <chasinglogic@gmail.com>2019-02-07 10:03:59 -0500
commitf981f6d69a66800632fe2083e92ed20d46729984 (patch)
tree43f9fff067fe6f316e95b60b1f8deb556e360d2d
parent683afc244ee5104372190d29c6905a868cb6a78d (diff)
downloadmongo-f981f6d69a66800632fe2083e92ed20d46729984.tar.gz
SERVER-39031 Make SCons default --jobs to CPU count
(cherry picked from commit 6fe1c12a764ed7b615399531e819b25a9d205993)
-rw-r--r--SConstruct17
1 files changed, 17 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index 4d52f24b85b..1512d3a4f52 100644
--- a/SConstruct
+++ b/SConstruct
@@ -13,6 +13,7 @@ import subprocess
import sys
import textwrap
import uuid
+import multiprocessing
import SCons
@@ -3285,6 +3286,22 @@ env.Alias("distsrc-tgz", env.GZip(
env.Alias("distsrc-zip", env.DistSrc("mongodb-src-${MONGO_VERSION}.zip"))
env.Alias("distsrc", "distsrc-tgz")
+# Defaults for SCons provided flags. SetOption only sets the option to our value
+# if the user did not provide it. So for any flag here if it's explicitly passed
+# the values below set with SetOption will be overwritten.
+#
+# Default j to the number of CPUs on the system. Note: in containers this
+# reports the number of CPUs for the host system. We're relying on the standard
+# library here and perhaps in a future version of Python it will instead report
+# the correct number when in a container.
+try:
+ env.SetOption('num_jobs', multiprocessing.cpu_count())
+# On some platforms (like Windows) on Python 2.7 multiprocessing.cpu_count
+# is not implemented. After we upgrade to Python 3.4+ we can use alternative
+# methods that are cross-platform.
+except NotImplementedError:
+ pass
+
env.SConscript(
dirs=[
'src',