+#
+# 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')])