From 127cd43f2ae5bce3e58a8d42341e598c87dc59d6 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 15 Feb 2013 00:49:46 +0200 Subject: Autodetect CCache and use it if installed. --- environment.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'environment.py') diff --git a/environment.py b/environment.py index a6719b4c9..3d760f190 100755 --- a/environment.py +++ b/environment.py @@ -217,11 +217,12 @@ class Environment(): self.object_suffix = 'o' def get_c_compiler_exelist(self): + ccachelist = self.detect_ccache() evar = 'CC' if evar in os.environ: return os.environ[evar].split() - return self.default_c - + return ccachelist + self.default_c + def is_header(self, fname): suffix = fname.split('.')[-1] return suffix in header_suffixes @@ -272,11 +273,20 @@ class Environment(): return ArLinker(exelist) raise EnvironmentException('Unknown static linker "' + ' '.join(exelist) + '"') + def detect_ccache(self): + has_ccache = subprocess.call(['ccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if has_ccache == 0: + cmdlist = ['ccache'] + else: + cmdlist = [] + return cmdlist + def get_cxx_compiler_exelist(self): + ccachelist = self.detect_ccache() evar = 'CXX' if evar in os.environ: return os.environ[evar].split() - return self.default_cxx + return ccachelist + self.default_cxx def get_static_linker_exelist(self): evar = 'AR' -- cgit v1.3