Commit 1461117c authored by sgjesse@gmail.com's avatar sgjesse@gmail.com

Add option 'env' to the SCons build scripts to support overriding the

ENV part of the build environment. This is mostly to support Windows
builds in cases where SCons cannot find the correct paths to the
Windows SDK, as these paths cannot be passed through shell envrionment
variables.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@87 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 546b52c3
......@@ -299,6 +299,7 @@ def GetOptions():
result = Options()
result.Add('mode', 'compilation mode (debug, release)', 'release')
result.Add('sample', 'build sample (shell, process)', '')
result.Add('env', 'override environment settings (NAME1:value1,NAME2:value2)', '')
for (name, option) in SIMPLE_OPTIONS.items():
help = '%s (%s)' % (name, ", ".join(option['values']))
result.Add(name, help, option.get('default'))
......@@ -336,11 +337,12 @@ def VerifyOptions(env):
class BuildContext(object):
def __init__(self, options, samples):
def __init__(self, options, env_overrides, samples):
self.library_targets = []
self.cctest_targets = []
self.sample_targets = []
self.options = options
self.env_overrides = env_overrides
self.samples = samples
self.use_snapshot = (options['snapshot'] == 'on')
self.flags = None
......@@ -387,13 +389,24 @@ def PostprocessOptions(options):
options['arch'] = options['simulator']
def BuildSpecific(env, mode):
def ParseEnvOverrides(arg):
# The environment overrides are in the format NAME1:value1,NAME2:value2
overrides = {}
for override in arg.split(','):
pos = override.find(':')
if pos == -1:
continue
overrides[override[:pos].strip()] = override[pos+1:].strip()
return overrides
def BuildSpecific(env, mode, env_overrides):
options = {'mode': mode}
for option in SIMPLE_OPTIONS:
options[option] = env[option]
PostprocessOptions(options)
context = BuildContext(options, samples=SplitList(env['sample']))
context = BuildContext(options, env_overrides, samples=SplitList(env['sample']))
library_flags = context.AddRelevantFlags(os.environ, LIBRARY_FLAGS)
v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
......@@ -464,13 +477,14 @@ def Build():
env = Environment(options=opts)
Help(opts.GenerateHelpText(env))
VerifyOptions(env)
env_overrides = ParseEnvOverrides(env['env'])
libraries = []
cctests = []
samples = []
modes = SplitList(env['mode'])
for mode in modes:
context = BuildSpecific(env.Copy(), mode)
context = BuildSpecific(env.Copy(), mode, env_overrides)
libraries += context.library_targets
cctests += context.cctest_targets
samples += context.sample_targets
......
......@@ -97,6 +97,7 @@ def Abort(message):
def ConfigureObjectFiles():
env = Environment()
env.Replace(**context.flags['v8'])
env['ENV'].update(**context.env_overrides)
env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile $LOGFILE')
......
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