2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-25 19:30:04 +01:00

Interpret leftover arguments containing an equals sign

as environment variable definitions rather than commands
This commit is contained in:
Krzysztof Kosiński 2014-01-25 22:28:07 +01:00
parent e4afaa957e
commit 1986a6a80b
2 changed files with 17 additions and 2 deletions

View File

@ -35,6 +35,12 @@ commands = []
List of commands to execute extracted from the command-line. This list is consumed during the execution, see :py:func:`waflib.Scripting.run_commands`.
"""
envvars = []
"""
List of environment variable declarations placed after the Waf executable name.
These are detected by searching for "=" in the rest arguments.
"""
lockfile = os.environ.get('WAFLOCK', '.lock-waf_%s_build' % sys.platform)
platform = Utils.unversioned_sys_platform()
@ -227,9 +233,14 @@ class OptionsContext(Context.Context):
:param _args: arguments
:type _args: list of strings
"""
global options, commands
global options, commands, envvars
(options, leftover_args) = self.parser.parse_args(args=_args)
commands = leftover_args
for arg in leftover_args:
if '=' in arg:
envvars.append(arg)
else:
commands.append(arg)
if options.destdir:
options.destdir = os.path.abspath(os.path.expanduser(options.destdir))

View File

@ -187,6 +187,10 @@ def parse_options():
"""
Context.create_context('options').execute()
for var in Options.envvars:
(name, value) = var.split('=', 1)
os.environ[name.strip()] = value
if not Options.commands:
Options.commands = [default_cmd]
Options.commands = [x for x in Options.commands if x != 'options'] # issue 1076