summaryrefslogtreecommitdiffstats
path: root/scons/generic.py
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-02-10 16:34:51 -0700
committerBrian Paul <[email protected]>2009-02-10 16:34:51 -0700
commitee4c921b65fb76998711f3c40330505cbc49a0e0 (patch)
treeb4c702af3d93a76e204a3aad012541d4fbcb2101 /scons/generic.py
parent767b1acbb757186bde30973394f256ab7498a075 (diff)
parent14d808f8fdc41a26cea5264e47a24c903e54ce93 (diff)
Merge commit 'origin/gallium-0.2' into gallium-master-merge
Diffstat (limited to 'scons/generic.py')
-rw-r--r--scons/generic.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/scons/generic.py b/scons/generic.py
index 05f7356b762..23231966731 100644
--- a/scons/generic.py
+++ b/scons/generic.py
@@ -206,6 +206,25 @@ _bool_map = {
}
+def num_jobs():
+ try:
+ return int(os.environ['NUMBER_OF_PROCESSORS'])
+ except (ValueError, KeyError):
+ pass
+
+ try:
+ return os.sysconf('SC_NPROCESSORS_ONLN')
+ except (ValueError, OSError, AttributeError):
+ pass
+
+ try:
+ return int(os.popen2("sysctl -n hw.ncpu")[1].read())
+ except ValueError:
+ pass
+
+ return 1
+
+
def generate(env):
"""Common environment generation code"""
@@ -266,6 +285,10 @@ def generate(env):
# different scons versions building the same source file
env.SConsignFile(os.path.join(env['build'], '.sconsign'))
+ # Parallel build
+ if env.GetOption('num_jobs') <= 1:
+ env.SetOption('num_jobs', num_jobs())
+
# Summary
print
print ' platform=%s' % env['platform']
@@ -274,6 +297,7 @@ def generate(env):
print ' debug=%s' % ['no', 'yes'][env['debug']]
print ' profile=%s' % ['no', 'yes'][env['profile']]
print ' build=%s' % env['build']
+ print ' %s jobs' % env.GetOption('num_jobs')
print
# Load tool chain