waf: fix array access out of bounds exception in the check for flex
If flex is not installed the following expection is triggered:
Checking for flex
Checking for program 'flex' : not found
Traceback (most recent call last):
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Scripting.py", line 158, in waf_entry_point
run_commands()
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Scripting.py", line 251, in run_commands
ctx = run_command(cmd_name)
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Scripting.py", line 235, in run_command
ctx.execute()
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Configure.py", line 159, in execute
super(ConfigurationContext, self).execute()
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Context.py", line 204, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Context.py", line 286, in recurse
user_function(self)
File "/home/slow/git/samba/scratch/wscript", line 307, in configure
conf.RECURSE('source3')
File "./buildtools/wafsamba/samba_utils.py", line 66, in fun
return f(*k, **kw)
File "./buildtools/wafsamba/samba_utils.py", line 481, in RECURSE
return ctx.recurse(relpath)
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Context.py", line 286, in recurse
user_function(self)
File "/home/slow/git/samba/scratch/source3/wscript", line 1660, in configure
flex.configure(conf)
File "/home/slow/git/samba/scratch/third_party/waf/waflib/Tools/flex.py", line 59, in configure
if re.search (r"\\msys\\[0-9.]+\\bin\\flex.exe$", conf.env.FLEX[0]):
IndexError: list index out of range
This happens because when the detection of flex fails, an excpetion is
thrown in Configure.py:find_program by calling self.fatal(), but as
Configure.py:find_program() is called from
samba_waf18.py:find_program_samba() which sets the keyword argument
mandatory=False, Configure.py:conf:fun() catches the expection.
As a result in flex.py the call to conf.find_program('flex', var='FLEX')
does not abort and
if re.search (r"\\msys\\[0-9.]+\\bin\\flex.exe$", conf.env.FLEX[0])
is executed even though conf.env.FLEX is None.
As this is a not a problem of upstream Samba, but triggered by our
samba_waf18.py:find_program_samba(), I don't pursue an upstream
fix. Instead, just use conf.find_program() directly instead of the
wrapper in flex.py.
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>