SConstruct revision 2929
110448Snilay@cs.wisc.edu# -*- mode:python -*- 210448Snilay@cs.wisc.edu 310448Snilay@cs.wisc.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan 410448Snilay@cs.wisc.edu# All rights reserved. 510448Snilay@cs.wisc.edu# 610448Snilay@cs.wisc.edu# Redistribution and use in source and binary forms, with or without 710448Snilay@cs.wisc.edu# modification, are permitted provided that the following conditions are 810448Snilay@cs.wisc.edu# met: redistributions of source code must retain the above copyright 910448Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer; 1010448Snilay@cs.wisc.edu# redistributions in binary form must reproduce the above copyright 1110448Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer in the 1210448Snilay@cs.wisc.edu# documentation and/or other materials provided with the distribution; 1310448Snilay@cs.wisc.edu# neither the name of the copyright holders nor the names of its 1410448Snilay@cs.wisc.edu# contributors may be used to endorse or promote products derived from 1510448Snilay@cs.wisc.edu# this software without specific prior written permission. 1610448Snilay@cs.wisc.edu# 1710448Snilay@cs.wisc.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1810448Snilay@cs.wisc.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1910448Snilay@cs.wisc.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2010448Snilay@cs.wisc.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2110448Snilay@cs.wisc.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2210448Snilay@cs.wisc.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2310448Snilay@cs.wisc.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2410448Snilay@cs.wisc.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2510448Snilay@cs.wisc.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2610448Snilay@cs.wisc.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2710448Snilay@cs.wisc.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2810448Snilay@cs.wisc.edu# 2910448Snilay@cs.wisc.edu# Authors: Steve Reinhardt 3010448Snilay@cs.wisc.edu 3110448Snilay@cs.wisc.edu################################################### 3210448Snilay@cs.wisc.edu# 3310448Snilay@cs.wisc.edu# SCons top-level build description (SConstruct) file. 3410448Snilay@cs.wisc.edu# 3510448Snilay@cs.wisc.edu# While in this directory ('m5'), just type 'scons' to build the default 3610448Snilay@cs.wisc.edu# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 3710448Snilay@cs.wisc.edu# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 3810448Snilay@cs.wisc.edu# the optimized full-system version). 3910448Snilay@cs.wisc.edu# 4010448Snilay@cs.wisc.edu# You can build M5 in a different directory as long as there is a 4110448Snilay@cs.wisc.edu# 'build/<CONFIG>' somewhere along the target path. The build system 4210448Snilay@cs.wisc.edu# expects that all configs under the same build directory are being 4310448Snilay@cs.wisc.edu# built for the same host system. 4410448Snilay@cs.wisc.edu# 4510448Snilay@cs.wisc.edu# Examples: 4610448Snilay@cs.wisc.edu# 4710448Snilay@cs.wisc.edu# The following two commands are equivalent. The '-u' option tells 4810448Snilay@cs.wisc.edu# scons to search up the directory tree for this SConstruct file. 4910448Snilay@cs.wisc.edu# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug 5010448Snilay@cs.wisc.edu# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug 5110448Snilay@cs.wisc.edu# 5210448Snilay@cs.wisc.edu# The following two commands are equivalent and demonstrate building 5310448Snilay@cs.wisc.edu# in a directory outside of the source tree. The '-C' option tells 5410448Snilay@cs.wisc.edu# scons to chdir to the specified directory to find this SConstruct 5510448Snilay@cs.wisc.edu# file. 5610448Snilay@cs.wisc.edu# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug 5710448Snilay@cs.wisc.edu# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug 5810448Snilay@cs.wisc.edu# 5910448Snilay@cs.wisc.edu# You can use 'scons -H' to print scons options. If you're in this 6010448Snilay@cs.wisc.edu# 'm5' directory (or use -u or -C to tell scons where to find this 6110448Snilay@cs.wisc.edu# file), you can use 'scons -h' to print all the M5-specific build 6210448Snilay@cs.wisc.edu# options as well. 6310448Snilay@cs.wisc.edu# 6410448Snilay@cs.wisc.edu################################################### 6510448Snilay@cs.wisc.edu 6610448Snilay@cs.wisc.edu# Python library imports 6710448Snilay@cs.wisc.eduimport sys 6810448Snilay@cs.wisc.eduimport os 6910448Snilay@cs.wisc.edu 7010448Snilay@cs.wisc.edu# Check for recent-enough Python and SCons versions. If your system's 7110448Snilay@cs.wisc.edu# default installation of Python is not recent enough, you can use a 7210448Snilay@cs.wisc.edu# non-default installation of the Python interpreter by either (1) 7310448Snilay@cs.wisc.edu# rearranging your PATH so that scons finds the non-default 'python' 7410448Snilay@cs.wisc.edu# first or (2) explicitly invoking an alternative interpreter on the 7510448Snilay@cs.wisc.edu# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 7610448Snilay@cs.wisc.eduEnsurePythonVersion(2,4) 7710448Snilay@cs.wisc.edu 7810448Snilay@cs.wisc.edu# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 7910448Snilay@cs.wisc.edu# 3-element version number. 8010448Snilay@cs.wisc.edumin_scons_version = (0,96,91) 8110448Snilay@cs.wisc.edutry: 8210448Snilay@cs.wisc.edu EnsureSConsVersion(*min_scons_version) 8310448Snilay@cs.wisc.eduexcept: 8410448Snilay@cs.wisc.edu print "Error checking current SCons version." 8510448Snilay@cs.wisc.edu print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 8610448Snilay@cs.wisc.edu Exit(2) 8710448Snilay@cs.wisc.edu 8810448Snilay@cs.wisc.edu 8910448Snilay@cs.wisc.edu# The absolute path to the current directory (where this file lives). 9010448Snilay@cs.wisc.eduROOT = Dir('.').abspath 9110448Snilay@cs.wisc.edu 9210448Snilay@cs.wisc.edu# Paths to the M5 and external source trees. 9310448Snilay@cs.wisc.eduSRCDIR = os.path.join(ROOT, 'src') 9410448Snilay@cs.wisc.edu 9510448Snilay@cs.wisc.edu# tell python where to find m5 python code 9610448Snilay@cs.wisc.edusys.path.append(os.path.join(ROOT, 'src/python')) 9710448Snilay@cs.wisc.edu 9810448Snilay@cs.wisc.edu################################################### 9910448Snilay@cs.wisc.edu# 10010448Snilay@cs.wisc.edu# Figure out which configurations to set up based on the path(s) of 10110448Snilay@cs.wisc.edu# the target(s). 10210448Snilay@cs.wisc.edu# 10310448Snilay@cs.wisc.edu################################################### 10410448Snilay@cs.wisc.edu 10510448Snilay@cs.wisc.edu# Find default configuration & binary. 10610448Snilay@cs.wisc.eduDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 10710448Snilay@cs.wisc.edu 10810448Snilay@cs.wisc.edu# Ask SCons which directory it was invoked from. 10910448Snilay@cs.wisc.edulaunch_dir = GetLaunchDir() 11010448Snilay@cs.wisc.edu 11110448Snilay@cs.wisc.edu# Make targets relative to invocation directory 11210448Snilay@cs.wisc.eduabs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))), 11310448Snilay@cs.wisc.edu BUILD_TARGETS) 11410448Snilay@cs.wisc.edu 11510448Snilay@cs.wisc.edu# helper function: find last occurrence of element in list 11610448Snilay@cs.wisc.edudef rfind(l, elt, offs = -1): 11710448Snilay@cs.wisc.edu for i in range(len(l)+offs, 0, -1): 11810448Snilay@cs.wisc.edu if l[i] == elt: 11910448Snilay@cs.wisc.edu return i 12010448Snilay@cs.wisc.edu raise ValueError, "element not found" 12110448Snilay@cs.wisc.edu 12210448Snilay@cs.wisc.edu# Each target must have 'build' in the interior of the path; the 12310448Snilay@cs.wisc.edu# directory below this will determine the build parameters. For 12410448Snilay@cs.wisc.edu# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 12510448Snilay@cs.wisc.edu# recognize that ALPHA_SE specifies the configuration because it 12610448Snilay@cs.wisc.edu# follow 'build' in the bulid path. 12710448Snilay@cs.wisc.edu 12810448Snilay@cs.wisc.edu# Generate a list of the unique build roots and configs that the 12910448Snilay@cs.wisc.edu# collected targets reference. 13010448Snilay@cs.wisc.edubuild_paths = [] 13110448Snilay@cs.wisc.edubuild_root = None 13210448Snilay@cs.wisc.edufor t in abs_targets: 13310448Snilay@cs.wisc.edu path_dirs = t.split('/') 13410448Snilay@cs.wisc.edu try: 13510448Snilay@cs.wisc.edu build_top = rfind(path_dirs, 'build', -2) 13610448Snilay@cs.wisc.edu except: 13710448Snilay@cs.wisc.edu print "Error: no non-leaf 'build' dir found on target path", t 13810448Snilay@cs.wisc.edu Exit(1) 13910448Snilay@cs.wisc.edu this_build_root = os.path.join('/',*path_dirs[:build_top+1]) 14010448Snilay@cs.wisc.edu if not build_root: 14110448Snilay@cs.wisc.edu build_root = this_build_root 14210448Snilay@cs.wisc.edu else: 14310448Snilay@cs.wisc.edu if this_build_root != build_root: 14410448Snilay@cs.wisc.edu print "Error: build targets not under same build root\n"\ 14510448Snilay@cs.wisc.edu " %s\n %s" % (build_root, this_build_root) 14610448Snilay@cs.wisc.edu Exit(1) 14710448Snilay@cs.wisc.edu build_path = os.path.join('/',*path_dirs[:build_top+2]) 14810448Snilay@cs.wisc.edu if build_path not in build_paths: 14910448Snilay@cs.wisc.edu build_paths.append(build_path) 15010448Snilay@cs.wisc.edu 15110448Snilay@cs.wisc.edu################################################### 15210448Snilay@cs.wisc.edu# 15310448Snilay@cs.wisc.edu# Set up the default build environment. This environment is copied 15410448Snilay@cs.wisc.edu# and modified according to each selected configuration. 15510448Snilay@cs.wisc.edu# 15610448Snilay@cs.wisc.edu################################################### 15710448Snilay@cs.wisc.edu 15810448Snilay@cs.wisc.eduenv = Environment(ENV = os.environ, # inherit user's environment vars 15910448Snilay@cs.wisc.edu ROOT = ROOT, 16010448Snilay@cs.wisc.edu SRCDIR = SRCDIR) 16110448Snilay@cs.wisc.edu 16210448Snilay@cs.wisc.eduenv.SConsignFile(os.path.join(build_root,"sconsign")) 16310448Snilay@cs.wisc.edu 16410448Snilay@cs.wisc.edu# Default duplicate option is to use hard links, but this messes up 16510448Snilay@cs.wisc.edu# when you use emacs to edit a file in the target dir, as emacs moves 16610448Snilay@cs.wisc.edu# file to file~ then copies to file, breaking the link. Symbolic 16710448Snilay@cs.wisc.edu# (soft) links work better. 16810448Snilay@cs.wisc.eduenv.SetOption('duplicate', 'soft-copy') 16910448Snilay@cs.wisc.edu 17010448Snilay@cs.wisc.edu# I waffle on this setting... it does avoid a few painful but 17110448Snilay@cs.wisc.edu# unnecessary builds, but it also seems to make trivial builds take 17210448Snilay@cs.wisc.edu# noticeably longer. 17310448Snilay@cs.wisc.eduif False: 17410448Snilay@cs.wisc.edu env.TargetSignatures('content') 17510448Snilay@cs.wisc.edu 17610448Snilay@cs.wisc.edu# M5_PLY is used by isa_parser.py to find the PLY package. 17710448Snilay@cs.wisc.eduenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 17810448Snilay@cs.wisc.edu 17910448Snilay@cs.wisc.edu# Set up default C++ compiler flags 18010448Snilay@cs.wisc.eduenv.Append(CCFLAGS='-pipe') 18110448Snilay@cs.wisc.eduenv.Append(CCFLAGS='-fno-strict-aliasing') 18210448Snilay@cs.wisc.eduenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 18310448Snilay@cs.wisc.eduif sys.platform == 'cygwin': 18410448Snilay@cs.wisc.edu # cygwin has some header file issues... 18510448Snilay@cs.wisc.edu env.Append(CCFLAGS=Split("-Wno-uninitialized")) 18610448Snilay@cs.wisc.eduenv.Append(CPPPATH=[Dir('ext/dnet')]) 18710448Snilay@cs.wisc.edu 18810448Snilay@cs.wisc.edu# Find Python include and library directories for embedding the 18910448Snilay@cs.wisc.edu# interpreter. For consistency, we will use the same Python 19010448Snilay@cs.wisc.edu# installation used to run scons (and thus this script). If you want 19110448Snilay@cs.wisc.edu# to link in an alternate version, see above for instructions on how 19210448Snilay@cs.wisc.edu# to invoke scons with a different copy of the Python interpreter. 19310448Snilay@cs.wisc.edu 19410448Snilay@cs.wisc.edu# Get brief Python version name (e.g., "python2.4") for locating 19510448Snilay@cs.wisc.edu# include & library files 19610448Snilay@cs.wisc.edupy_version_name = 'python' + sys.version[:3] 19710448Snilay@cs.wisc.edu 19810448Snilay@cs.wisc.edu# include path, e.g. /usr/local/include/python2.4 19910448Snilay@cs.wisc.eduenv.Append(CPPPATH = os.path.join(sys.exec_prefix, 'include', py_version_name)) 20010448Snilay@cs.wisc.eduenv.Append(LIBS = py_version_name) 20110448Snilay@cs.wisc.edu# add library path too if it's not in the default place 20210448Snilay@cs.wisc.eduif sys.exec_prefix != '/usr': 20310448Snilay@cs.wisc.edu env.Append(LIBPATH = os.path.join(sys.exec_prefix, 'lib')) 20410448Snilay@cs.wisc.edu 20510448Snilay@cs.wisc.edu# Set up SWIG flags & scanner 20610448Snilay@cs.wisc.edu 20710448Snilay@cs.wisc.eduenv.Append(SWIGFLAGS=Split('-c++ -python -modern $_CPPINCFLAGS')) 20810448Snilay@cs.wisc.edu 20910448Snilay@cs.wisc.eduimport SCons.Scanner 21010448Snilay@cs.wisc.edu 21110448Snilay@cs.wisc.eduswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 21210448Snilay@cs.wisc.edu 21310448Snilay@cs.wisc.eduswig_scanner = SCons.Scanner.ClassicCPP("SwigScan", ".i", "CPPPATH", 214 swig_inc_re) 215 216env.Append(SCANNERS = swig_scanner) 217 218# Other default libraries 219env.Append(LIBS=['z']) 220 221# Platform-specific configuration. Note again that we assume that all 222# builds under a given build root run on the same host platform. 223conf = Configure(env, 224 conf_dir = os.path.join(build_root, '.scons_config'), 225 log_file = os.path.join(build_root, 'scons_config.log')) 226 227# Check for <fenv.h> (C99 FP environment control) 228have_fenv = conf.CheckHeader('fenv.h', '<>') 229if not have_fenv: 230 print "Warning: Header file <fenv.h> not found." 231 print " This host has no IEEE FP rounding mode control." 232 233# Check for mysql. 234mysql_config = WhereIs('mysql_config') 235have_mysql = mysql_config != None 236 237# Check MySQL version. 238if have_mysql: 239 mysql_version = os.popen(mysql_config + ' --version').read() 240 mysql_version = mysql_version.split('.') 241 mysql_major = int(mysql_version[0]) 242 mysql_minor = int(mysql_version[1]) 243 # This version check is probably overly conservative, but it deals 244 # with the versions we have installed. 245 if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1): 246 print "Warning: MySQL v4.1 or newer required." 247 have_mysql = False 248 249# Set up mysql_config commands. 250if have_mysql: 251 mysql_config_include = mysql_config + ' --include' 252 if os.system(mysql_config_include + ' > /dev/null') != 0: 253 # older mysql_config versions don't support --include, use 254 # --cflags instead 255 mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 256 # This seems to work in all versions 257 mysql_config_libs = mysql_config + ' --libs' 258 259env = conf.Finish() 260 261# Define the universe of supported ISAs 262env['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 263 264# Define the universe of supported CPU models 265env['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU', 266 'FullCPU', 'O3CPU', 267 'OzoneCPU'] 268 269# Sticky options get saved in the options file so they persist from 270# one invocation to the next (unless overridden, in which case the new 271# value becomes sticky). 272sticky_opts = Options(args=ARGUMENTS) 273sticky_opts.AddOptions( 274 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 275 BoolOption('FULL_SYSTEM', 'Full-system support', False), 276 # There's a bug in scons 0.96.1 that causes ListOptions with list 277 # values (more than one value) not to be able to be restored from 278 # a saved option file. If this causes trouble then upgrade to 279 # scons 0.96.90 or later. 280 ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU', 281 env['ALL_CPU_LIST']), 282 BoolOption('ALPHA_TLASER', 283 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 284 BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 285 BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 286 False), 287 BoolOption('SS_COMPATIBLE_FP', 288 'Make floating-point results compatible with SimpleScalar', 289 False), 290 BoolOption('USE_SSE2', 291 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 292 False), 293 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 294 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 295 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 296 ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 297 ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 298 BoolOption('BATCH', 'Use batch pool for build and tests', False), 299 ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 300 ) 301 302# Non-sticky options only apply to the current build. 303nonsticky_opts = Options(args=ARGUMENTS) 304nonsticky_opts.AddOptions( 305 BoolOption('update_ref', 'Update test reference outputs', False) 306 ) 307 308# These options get exported to #defines in config/*.hh (see src/SConscript). 309env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 310 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 311 'USE_CHECKER'] 312 313# Define a handy 'no-op' action 314def no_action(target, source, env): 315 return 0 316 317env.NoAction = Action(no_action, None) 318 319################################################### 320# 321# Define a SCons builder for configuration flag headers. 322# 323################################################### 324 325# This function generates a config header file that #defines the 326# option symbol to the current option setting (0 or 1). The source 327# operands are the name of the option and a Value node containing the 328# value of the option. 329def build_config_file(target, source, env): 330 (option, value) = [s.get_contents() for s in source] 331 f = file(str(target[0]), 'w') 332 print >> f, '#define', option, value 333 f.close() 334 return None 335 336# Generate the message to be printed when building the config file. 337def build_config_file_string(target, source, env): 338 (option, value) = [s.get_contents() for s in source] 339 return "Defining %s as %s in %s." % (option, value, target[0]) 340 341# Combine the two functions into a scons Action object. 342config_action = Action(build_config_file, build_config_file_string) 343 344# The emitter munges the source & target node lists to reflect what 345# we're really doing. 346def config_emitter(target, source, env): 347 # extract option name from Builder arg 348 option = str(target[0]) 349 # True target is config header file 350 target = os.path.join('config', option.lower() + '.hh') 351 # Force value to 0/1 even if it's a Python bool 352 val = int(eval(str(env[option]))) 353 # Sources are option name & value (packaged in SCons Value nodes) 354 return ([target], [Value(option), Value(val)]) 355 356config_builder = Builder(emitter = config_emitter, action = config_action) 357 358env.Append(BUILDERS = { 'ConfigFile' : config_builder }) 359 360################################################### 361# 362# Define a SCons builder for copying files. This is used by the 363# Python zipfile code in src/python/SConscript, but is placed up here 364# since it's potentially more generally applicable. 365# 366################################################### 367 368copy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 369 370env.Append(BUILDERS = { 'CopyFile' : copy_builder }) 371 372################################################### 373# 374# Define a simple SCons builder to concatenate files. 375# 376# Used to append the Python zip archive to the executable. 377# 378################################################### 379 380concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 381 'chmod +x $TARGET'])) 382 383env.Append(BUILDERS = { 'Concat' : concat_builder }) 384 385 386# base help text 387help_text = ''' 388Usage: scons [scons options] [build options] [target(s)] 389 390''' 391 392# libelf build is shared across all configs in the build root. 393env.SConscript('ext/libelf/SConscript', 394 build_dir = os.path.join(build_root, 'libelf'), 395 exports = 'env') 396 397################################################### 398# 399# Define build environments for selected configurations. 400# 401################################################### 402 403# rename base env 404base_env = env 405 406for build_path in build_paths: 407 print "Building in", build_path 408 # build_dir is the tail component of build path, and is used to 409 # determine the build parameters (e.g., 'ALPHA_SE') 410 (build_root, build_dir) = os.path.split(build_path) 411 # Make a copy of the build-root environment to use for this config. 412 env = base_env.Copy() 413 414 # Set env options according to the build directory config. 415 sticky_opts.files = [] 416 # Options for $BUILD_ROOT/$BUILD_DIR are stored in 417 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 418 # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 419 current_opts_file = os.path.join(build_root, 'options', build_dir) 420 if os.path.isfile(current_opts_file): 421 sticky_opts.files.append(current_opts_file) 422 print "Using saved options file %s" % current_opts_file 423 else: 424 # Build dir-specific options file doesn't exist. 425 426 # Make sure the directory is there so we can create it later 427 opt_dir = os.path.dirname(current_opts_file) 428 if not os.path.isdir(opt_dir): 429 os.mkdir(opt_dir) 430 431 # Get default build options from source tree. Options are 432 # normally determined by name of $BUILD_DIR, but can be 433 # overriden by 'default=' arg on command line. 434 default_opts_file = os.path.join('build_opts', 435 ARGUMENTS.get('default', build_dir)) 436 if os.path.isfile(default_opts_file): 437 sticky_opts.files.append(default_opts_file) 438 print "Options file %s not found,\n using defaults in %s" \ 439 % (current_opts_file, default_opts_file) 440 else: 441 print "Error: cannot find options file %s or %s" \ 442 % (current_opts_file, default_opts_file) 443 Exit(1) 444 445 # Apply current option settings to env 446 sticky_opts.Update(env) 447 nonsticky_opts.Update(env) 448 449 help_text += "Sticky options for %s:\n" % build_dir \ 450 + sticky_opts.GenerateHelpText(env) \ 451 + "\nNon-sticky options for %s:\n" % build_dir \ 452 + nonsticky_opts.GenerateHelpText(env) 453 454 # Process option settings. 455 456 if not have_fenv and env['USE_FENV']: 457 print "Warning: <fenv.h> not available; " \ 458 "forcing USE_FENV to False in", build_dir + "." 459 env['USE_FENV'] = False 460 461 if not env['USE_FENV']: 462 print "Warning: No IEEE FP rounding mode control in", build_dir + "." 463 print " FP results may deviate slightly from other platforms." 464 465 if env['EFENCE']: 466 env.Append(LIBS=['efence']) 467 468 if env['USE_MYSQL']: 469 if not have_mysql: 470 print "Warning: MySQL not available; " \ 471 "forcing USE_MYSQL to False in", build_dir + "." 472 env['USE_MYSQL'] = False 473 else: 474 print "Compiling in", build_dir, "with MySQL support." 475 env.ParseConfig(mysql_config_libs) 476 env.ParseConfig(mysql_config_include) 477 478 # Save sticky option settings back to current options file 479 sticky_opts.Save(current_opts_file, env) 480 481 # Do this after we save setting back, or else we'll tack on an 482 # extra 'qdo' every time we run scons. 483 if env['BATCH']: 484 env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 485 env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 486 487 if env['USE_SSE2']: 488 env.Append(CCFLAGS='-msse2') 489 490 # The src/SConscript file sets up the build rules in 'env' according 491 # to the configured options. It returns a list of environments, 492 # one for each variant build (debug, opt, etc.) 493 envList = SConscript('src/SConscript', build_dir = build_path, 494 exports = 'env') 495 496 # Set up the regression tests for each build. 497 for e in envList: 498 SConscript('tests/SConscript', 499 build_dir = os.path.join(build_path, 'test', e.Label), 500 exports = { 'env' : e }, duplicate = False) 501 502Help(help_text) 503 504################################################### 505# 506# Let SCons do its thing. At this point SCons will use the defined 507# build environments to build the requested targets. 508# 509################################################### 510 511