Commit 8947c308 authored by ager@chromium.org's avatar ager@chromium.org

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
parent 8389e4f9
...@@ -507,7 +507,8 @@ def GetOptions(): ...@@ -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): ...@@ -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(): ...@@ -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'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment