Apply Lei Zhang's patch to add easy import of additional environment

variables in our scons setup.

Here is an example of importing an additional environment variable:

export MYVAR='value'
scons importenv="MYVAR"

Review URL: http://codereview.chromium.org/60046

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1671 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ager@chromium.org 2009-04-02 13:00:28 +00:00
parent 8389e4f9f8
commit 8947c308c6

View File

@ -507,7 +507,8 @@ def GetOptions():
result = Options() result = Options()
result.Add('mode', 'compilation mode (debug, release)', 'release') result.Add('mode', 'compilation mode (debug, release)', 'release')
result.Add('sample', 'build sample (shell, process)', '') result.Add('sample', 'build sample (shell, process)', '')
result.Add('env', 'override environment settings (NAME1:value1,NAME2:value2)', '') result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
for (name, option) in SIMPLE_OPTIONS.iteritems(): for (name, option) in SIMPLE_OPTIONS.iteritems():
help = '%s (%s)' % (name, ", ".join(option['values'])) help = '%s (%s)' % (name, ", ".join(option['values']))
result.Add(name, help, option.get('default')) result.Add(name, help, option.get('default'))
@ -626,9 +627,13 @@ def PostprocessOptions(options):
options['arch'] = options['simulator'] options['arch'] = options['simulator']
def ParseEnvOverrides(arg): def ParseEnvOverrides(arg, imports):
# The environment overrides are in the format NAME1:value1,NAME2:value2 # The environment overrides are in the format NAME0:value0,NAME1:value1,...
# The environment imports are in the format NAME0,NAME1,...
overrides = {} overrides = {}
for var in imports.split(','):
if var in os.environ:
overrides[var] = os.environ[var]
for override in arg.split(','): for override in arg.split(','):
pos = override.find(':') pos = override.find(':')
if pos == -1: if pos == -1:
@ -726,7 +731,7 @@ def Build():
env = Environment(options=opts) env = Environment(options=opts)
Help(opts.GenerateHelpText(env)) Help(opts.GenerateHelpText(env))
VerifyOptions(env) VerifyOptions(env)
env_overrides = ParseEnvOverrides(env['env']) env_overrides = ParseEnvOverrides(env['env'], env['importenv'])
SourceSignatures(env['sourcesignatures']) SourceSignatures(env['sourcesignatures'])