From 2262f1009b67ccf262eec178c1511ec753896a17 Mon Sep 17 00:00:00 2001 From: Harald Klimach Date: Wed, 23 Dec 2015 14:32:52 +0100 Subject: [PATCH] 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. --- waflib/Tools/fc_config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/waflib/Tools/fc_config.py b/waflib/Tools/fc_config.py index 7890abde..866a74b1 100644 --- a/waflib/Tools/fc_config.py +++ b/waflib/Tools/fc_config.py @@ -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)