-env.SetOption('duplicate', 'soft-copy')
-
-# I waffle on this setting... it does avoid a few painful but
-# unnecessary builds, but it also seems to make trivial builds take
-# noticeably longer.
-if False:
- env.TargetSignatures('content')
-
-# M5_PLY is used by isa_parser.py to find the PLY package.
-env.Append(ENV = { 'M5_PLY' : Dir('ext/ply') })
-env['GCC'] = False
-env['SUNCC'] = False
-env['ICC'] = False
-env['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- close_fds=True).communicate()[0].find('GCC') >= 0
-env['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- close_fds=True).communicate()[0].find('Sun C++') >= 0
-env['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- close_fds=True).communicate()[0].find('Intel') >= 0
-if env['GCC'] + env['SUNCC'] + env['ICC'] > 1:
+main.SetOption('duplicate', 'soft-copy')
+
+#
+# Set up global sticky variables... these are common to an entire build
+# tree (not specific to a particular build like ALPHA_SE)
+#
+
+# Variable validators & converters for global sticky variables
+def PathListMakeAbsolute(val):
+ if not val:
+ return val
+ f = lambda p: abspath(expanduser(p))
+ return ':'.join(map(f, val.split(':')))
+
+def PathListAllExist(key, val, env):
+ if not val:
+ return
+ paths = val.split(':')
+ for path in paths:
+ if not isdir(path):
+ raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
+
+global_sticky_vars_file = joinpath(build_root, 'variables.global')
+
+global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS)
+
+global_sticky_vars.AddVariables(
+ ('CC', 'C compiler', environ.get('CC', main['CC'])),
+ ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
+ ('BATCH', 'Use batch pool for build and tests', False),
+ ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
+ ('EXTRAS', 'Add Extra directories to the compilation', '',
+ PathListAllExist, PathListMakeAbsolute),
+ BoolVariable('RUBY', 'Build with Ruby', False),
+ )
+
+# base help text
+help_text = '''
+Usage: scons [scons options] [build options] [target(s)]
+
+Global sticky options:
+'''
+
+help_text += global_sticky_vars.GenerateHelpText(main)
+
+# Update main environment with values from ARGUMENTS & global_sticky_vars_file
+global_sticky_vars.Update(main)
+
+# Save sticky variable settings back to current variables file
+global_sticky_vars.Save(global_sticky_vars_file, main)
+
+# Parse EXTRAS variable to build list of all directories where we're
+# look for sources etc. This list is exported as base_dir_list.
+base_dir = main.srcdir.abspath
+if main['EXTRAS']:
+ extras_dir_list = main['EXTRAS'].split(':')
+else:
+ extras_dir_list = []
+
+Export('base_dir')
+Export('extras_dir_list')
+
+# the ext directory should be on the #includes path
+main.Append(CPPPATH=[Dir('ext')])
+
+CXX_version = readCommand([main['CXX'],'--version'], exception=False)
+CXX_V = readCommand([main['CXX'],'-V'], exception=False)
+
+main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
+main['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0
+main['ICC'] = CXX_V and CXX_V.find('Intel') >= 0
+if main['GCC'] + main['SUNCC'] + main['ICC'] > 1: