diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-09-29 14:08:53 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-09-29 14:17:26 +0100 |
commit | 67450f0644f61fc17ab1315124dfe50537d36e9e (patch) | |
tree | fa0c928ce60e59ad292754629d2aaa97134549bd /scons | |
parent | fdcc168a16d59bf2b7fd291383f214834c2546f6 (diff) |
scons: New build= option, with support for checked builds.
Where checked build is compiler optimizations plus debugging checks --
ideal for testing CPU bound loads and running test automation loads.
Diffstat (limited to 'scons')
-rw-r--r-- | scons/gallium.py | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/scons/gallium.py b/scons/gallium.py index f5de4718ee..97b4721663 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -49,14 +49,14 @@ def symlink(target, source, env): os.symlink(os.path.basename(source), target) def install(env, source, subdir): - target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], subdir) + target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir) env.Install(target_dir, source) def install_program(env, source): install(env, source, 'bin') def install_shared_library(env, sources, version = ()): - install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build']) + install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir']) version = tuple(map(str, version)) if env['SHLIBSUFFIX'] == '.dll': dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX') @@ -138,20 +138,42 @@ def generate(env): gcc = env['gcc'] msvc = env['msvc'] + # Backwards compatability with the debug= profile= options + if env['build'] == 'debug': + if not env['debug']: + print 'scons: debug option is deprecated: use instead build=release' + env['build'] = 'release' + if env['profile']: + print 'scons: profile option is deprecated: use instead build=profile' + env['build'] = 'profile' + if False: + # Enforce SConscripts to use the new build variable + env.popitem('debug') + env.popitem('profile') + else: + # Backwards portability with older sconscripts + if env['build'] in ('debug', 'checked'): + env['debug'] = True + env['profile'] = False + if env['build'] == 'profile': + env['debug'] = False + env['profile'] = True + if env['build'] == 'release': + env['debug'] = False + env['profile'] = False + # Put build output in a separate dir, which depends on the current # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample build_topdir = 'build' build_subdir = env['platform'] if env['machine'] != 'generic': build_subdir += '-' + env['machine'] - if env['debug']: - build_subdir += "-debug" - if env['profile']: - build_subdir += "-profile" + if env['build'] != 'release': + build_subdir += '-' + env['build'] build_dir = os.path.join(build_topdir, build_subdir) # Place the .sconsign file in the build dir too, to avoid issues with # different scons versions building the same source file - env['build'] = build_dir + env['build_dir'] = build_dir env.SConsignFile(os.path.join(build_dir, '.sconsign')) if 'SCONS_CACHE_DIR' in os.environ: print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],) @@ -165,11 +187,11 @@ def generate(env): # C preprocessor options cppdefines = [] - if debug: + if env['build'] in ('debug', 'checked'): cppdefines += ['DEBUG'] else: cppdefines += ['NDEBUG'] - if env['profile']: + if env['build'] == 'profile': cppdefines += ['PROFILE'] if platform == 'windows': cppdefines += [ @@ -190,7 +212,7 @@ def generate(env): '_SCL_SECURE_NO_WARNINGS', '_SCL_SECURE_NO_DEPRECATE', ] - if debug: + if env['build'] in ('debug', 'checked'): cppdefines += ['_DEBUG'] if env['toolchain'] == 'winddk': # Mimic WINDDK's builtin flags. See also: @@ -217,7 +239,7 @@ def generate(env): ('__BUILDMACHINE__', 'WinDDK'), ('FPO', '0'), ] - if debug: + if env['build'] in ('debug', 'checked'): cppdefines += [('DBG', 1)] if platform == 'wince': cppdefines += [ @@ -253,15 +275,16 @@ def generate(env): ccflags = [] # C & C++ if gcc: ccversion = env['CCVERSION'] - if debug: - ccflags += ['-O0', '-g3'] + if env['build'] == 'debug': + ccflags += ['-O0'] elif ccversion.startswith('4.2.'): # gcc 4.2.x optimizer is broken print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations" - ccflags += ['-O0', '-g3'] + ccflags += ['-O0'] else: - ccflags += ['-O3', '-g3'] - if env['profile']: + ccflags += ['-O3'] + ccflags += ['-g3'] + if env['build'] in ('checked', 'profile'): # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling? ccflags += [ '-fno-omit-frame-pointer', @@ -320,7 +343,7 @@ def generate(env): # See also: # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx # - cl /? - if debug: + if env['build'] == 'debug': ccflags += [ '/Od', # disable optimizations '/Oi', # enable intrinsic functions @@ -460,7 +483,7 @@ def generate(env): '/entry:DrvEnableDriver', ] - if env['debug'] or env['profile']: + if env['build'] != 'release': linkflags += [ '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx ] |