Use all available CPUs when building
authorRasmus Andersson <rasmus@notion.se>
Sun, 27 Jun 2010 11:51:39 +0000 (13:51 +0200)
committerRyan Dahl <ry@tinyclouds.org>
Sun, 27 Jun 2010 15:49:06 +0000 (08:49 -0700)
Automatically set Options.options.jobs to the number of CPUs/cores on the
executing machine, unless the environment variable JOBS is set

wscript

diff --git a/wscript b/wscript
index 6a5726c794ff7e3ca0647380776c1a36e5b3dd49..b6f83806962b080d338ae77186f8092ee4a71011 100644 (file)
--- a/wscript
+++ b/wscript
@@ -19,6 +19,12 @@ blddir = 'build'
 jobs=1
 if os.environ.has_key('JOBS'):
   jobs = int(os.environ['JOBS'])
+else:
+  try:
+    import multiprocessing
+    jobs = multiprocessing.cpu_count()
+  except:
+    pass
 
 def set_options(opt):
   # the gcc module provides a --debug-level option