Ignore error codes from cmd_and_log in getoutput that is used to obtain

the version string of Fortran compilers.
Some compilers will fail and return an error code if not provided with
a source file, yet they print the desired version string.
Thus, in case of an error code we ignore it here and just pass on the
stdout and stderr of the called subprocess.
This commit is contained in:
Harald Klimach 2015-12-23 14:32:52 +01:00
parent 6132c8e055
commit 2262f1009b
1 changed files with 7 additions and 0 deletions

View File

@ -336,6 +336,7 @@ def getoutput(conf, cmd, stdin=False):
TODO a bit redundant, can be removed anytime
TODO waf 1.9
"""
from waflib import Errors
if conf.env.env:
env = conf.env.env
else:
@ -344,6 +345,12 @@ def getoutput(conf, cmd, stdin=False):
input = stdin and '\n'.encode() or None
try:
out, err = conf.cmd_and_log(cmd, env=env, output=0, input=input)
except Errors.WafError as e:
# Some compilers will return an error code if no source file
# is provided. Nevertheless, they print a version string and
# we can ignore the error code here.
out = e.stdout
err = e.stderr
except Exception:
conf.fatal('could not determine the compiler version %r' % cmd)
return (out, err)