From cfc3605b730060b41856d3029dcfffc1ccce7ce6 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 24 Mar 2017 19:04:43 +0530 Subject: [PATCH] Detect 'ccache' in evars and cross-info files Then, only use it if it's actually available. Closes https://github.com/mesonbuild/meson/issues/1471 --- mesonbuild/environment.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 521762659..92040c45d 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -377,16 +377,30 @@ class Environment: C, C++, ObjC, ObjC++, Fortran so consolidate it here. ''' if self.is_cross_build() and want_cross: - compilers = [mesonlib.stringlistify(self.cross_info.config['binaries'][lang])] - ccache = [] + compilers = mesonlib.stringlistify(self.cross_info.config['binaries'][lang]) + # Ensure ccache exists and remove it if it doesn't + if compilers[0] == 'ccache': + compilers = compilers[1:] + ccache = self.detect_ccache() + else: + ccache = [] + # Return value has to be a list of compiler 'choices' + compilers = [compilers] is_cross = True if self.cross_info.need_exe_wrapper(): exe_wrap = self.cross_info.config['binaries'].get('exe_wrapper', None) else: exe_wrap = [] elif evar in os.environ: - compilers = [shlex.split(os.environ[evar])] - ccache = [] + compilers = shlex.split(os.environ[evar]) + # Ensure ccache exists and remove it if it doesn't + if compilers[0] == 'ccache': + compilers = compilers[1:] + ccache = self.detect_ccache() + else: + ccache = [] + # Return value has to be a list of compiler 'choices' + compilers = [compilers] is_cross = False exe_wrap = None else: