diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-04-11 14:43:43 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-04-22 13:49:50 -0700 |
commit | b8ec23b69dadbda772f671b0c2f4c4ef662971ea (patch) | |
tree | 1fc974b50e767f1aa61eabf603ba16579719e1f2 | |
parent | d81dfcba74b8168a242dc2f582244dd1f675c99a (diff) | |
download | meson-b8ec23b69dadbda772f671b0c2f4c4ef662971ea.zip meson-b8ec23b69dadbda772f671b0c2f4c4ef662971ea.tar.gz meson-b8ec23b69dadbda772f671b0c2f4c4ef662971ea.tar.bz2 |
envconfig: simplify exception handling.
Currently this takes a return value, and in the error case sets it,
then has a separate if to hanle that. Instead just set the return
value in the error handler.
-rw-r--r-- | mesonbuild/envconfig.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index e211945..d3b1989 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -327,17 +327,13 @@ class BinaryTable(HasEnvVarFallback): 'pkgconfig': 'PKG_CONFIG', } - @classmethod - def detect_ccache(cls): + @staticmethod + def detect_ccache(): try: - has_ccache = subprocess.call(['ccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - except OSError: - has_ccache = 1 - if has_ccache == 0: - cmdlist = ['ccache'] - else: - cmdlist = [] - return cmdlist + subprocess.check_call(['ccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except (OSError, subprocess.CalledProcessError): + return [] + return ['ccache'] @classmethod def _warn_about_lang_pointing_to_cross(cls, compiler_exe, evar): |