diff options
Diffstat (limited to 'scons')
-rw-r--r-- | scons/gallium.py | 31 | ||||
-rw-r--r-- | scons/generic.py | 32 |
2 files changed, 61 insertions, 2 deletions
diff --git a/scons/gallium.py b/scons/gallium.py index 065c53c54b..d20d02ca20 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: @@ -324,6 +347,7 @@ def generate(env): '/Od', # disable optimizations '/Oi', # enable intrinsic functions '/Oy-', # disable frame pointer omission + '/GL-', # disable whole program optimization ] else: cflags += [ @@ -414,10 +438,15 @@ def generate(env): linkflags += ['-m32'] if env['machine'] == 'x86_64': linkflags += ['-m64'] - if platform == 'winddk': + if platform == 'windows' and msvc: # See also: # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx linkflags += [ + '/fixed:no', + '/incremental:no', + ] + if platform == 'winddk': + linkflags += [ '/merge:_PAGE=PAGE', '/merge:_TEXT=.text', '/section:INIT,d', diff --git a/scons/generic.py b/scons/generic.py index 05f7356b76..7592222fd6 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 @@ -401,6 +425,7 @@ def generate(env): '/Od', # disable optimizations '/Oi', # enable intrinsic functions '/Oy-', # disable frame pointer omission + '/GL-', # disable whole program optimization ] else: ccflags += [ @@ -492,10 +517,15 @@ def generate(env): linkflags += ['-m32'] if env['machine'] == 'x86_64': linkflags += ['-m64'] - if platform == 'winddk': + if platform == 'windows' and msvc: # See also: # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx linkflags += [ + '/fixed:no', + '/incremental:no', + ] + if platform == 'winddk': + linkflags += [ '/merge:_PAGE=PAGE', '/merge:_TEXT=.text', '/section:INIT,d', |