summaryrefslogtreecommitdiffstats
path: root/scons/gallium.py
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-02-10 18:11:56 +0000
committerJosé Fonseca <[email protected]>2009-02-10 18:13:05 +0000
commit1e8177ee178b131afa86d874b062a8ae3fae0cca (patch)
treec365907dc8d66c2d6197a3a7f21deeecb280bae6 /scons/gallium.py
parent02401cbaf021833c77c501d697d912f295546f58 (diff)
scons: Use parallel builds by default.
Diffstat (limited to 'scons/gallium.py')
-rw-r--r--scons/gallium.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/scons/gallium.py b/scons/gallium.py
index 065c53c54b2..fc1ed08e478 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -163,6 +163,25 @@ def createInstallMethods(env):
env.AddMethod(install_shared_library, 'InstallSharedLibrary')
+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"""
@@ -207,6 +226,10 @@ def generate(env):
env.SConsignFile(os.path.join(build_dir, '.sconsign'))
env.CacheDir('build/cache')
+ # Parallel build
+ if env.GetOption('num_jobs') <= 1:
+ env.SetOption('num_jobs', num_jobs())
+
# C preprocessor options
cppdefines = []
if debug: