Merge branch 'winres-cmd-fix' into 'master'

Change winres.py exec_command to not empty the cmd list.

See merge request ita1024/waf!2326
This commit is contained in:
Erik Parker 2021-09-29 05:28:05 +00:00
commit 39ba043919
1 changed files with 20 additions and 3 deletions

View File

@ -69,12 +69,29 @@ class winrc(Task.Task):
# response files and are best passed as environment variables
replace_cmd = []
incpaths = []
while cmd:
# Work off of a copy of cmd. cmd is essentially passed by reference,
# so if we pop items off of it, that modifies the version of cmd
# that is passed into this function. Normally this might only
# manifest as some weirdness if someone walks up the stack with
# the debugger. That person would get to whoever called this
# function and see that the original cmd was empty. gcc_color.py's
# format function walks up the stack and access the cmd variable,
# which is the cmd variable at the time this function is called.
# Since this function was popping elements off of cmd and eventually
# replacing cmd with replace_cmd, by the time the fiormat function
# got to caller function cmd was empty. Since format only tests to
# see if cmd is a list and not if cmd is empty, format was throwing
# an IndexException. We fi the issue here by operating off of a copy
# of cmd instead of operating off of the original. That does mean
# that after this function cmd will be different, but that shouldn't
# caudse any other headaches.
working_cmd = cmd[:]
while working_cmd:
# filter include path flags
flag = cmd.pop(0)
flag = working_cmd.pop(0)
if flag.upper().startswith('/I'):
if len(flag) == 2:
incpaths.append(cmd.pop(0))
incpaths.append(working_cmd.pop(0))
else:
incpaths.append(flag[2:])
else: