From 67450f0644f61fc17ab1315124dfe50537d36e9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 29 Sep 2010 14:08:53 +0100 Subject: [PATCH] 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. --- SConstruct | 2 +- common.py | 6 +++-- scons/gallium.py | 59 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/SConstruct b/SConstruct index 02e99f67aa8..558ebf90aaa 100644 --- a/SConstruct +++ b/SConstruct @@ -208,7 +208,7 @@ Export('env') SConscript( 'src/SConscript', - variant_dir = env['build'], + variant_dir = env['build_dir'], duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html ) diff --git a/common.py b/common.py index 7a14a2c026d..13e8dc83e97 100644 --- a/common.py +++ b/common.py @@ -81,8 +81,8 @@ def AddOptions(opts): from SCons.Variables.EnumVariable import EnumVariable as EnumOption except ImportError: from SCons.Options.EnumOption import EnumOption - opts.Add(BoolOption('debug', 'debug build', 'yes')) - opts.Add(BoolOption('profile', 'profile build', 'no')) + opts.Add(EnumOption('build', 'build type', 'debug', + allowed_values=('debug', 'checked', 'profile', 'release'))) opts.Add(BoolOption('quiet', 'quiet command lines', 'yes')) opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) @@ -91,3 +91,5 @@ def AddOptions(opts): opts.Add('toolchain', 'compiler toolchain', 'default') opts.Add(BoolOption('llvm', 'use LLVM', default_llvm)) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) + opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes')) + opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no')) diff --git a/scons/gallium.py b/scons/gallium.py index f5de4718eea..97b47216636 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 ] -- 2.30.2