+#
+# 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', env['CC'])),
+ ('CXX', 'C++ compiler', environ.get('CXX', env['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)
+ )
+
+# base help text
+help_text = '''
+Usage: scons [scons options] [build options] [target(s)]
+
+Global sticky options:
+'''
+
+help_text += global_sticky_vars.GenerateHelpText(env)
+
+# Update env with values from ARGUMENTS & file global_sticky_vars_file
+global_sticky_vars.Update(env)
+
+# Save sticky variable settings back to current variables file
+global_sticky_vars.Save(global_sticky_vars_file, env)
+
+# 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 = env.srcdir.abspath
+if env['EXTRAS']:
+ extras_dir_list = env['EXTRAS'].split(':')
+else:
+ extras_dir_list = []
+
+Export('base_dir')
+Export('extras_dir_list')
+
+# the ext directory should be on the #includes path
+env.Append(CPPPATH=[Dir('ext')])