Add sccache support.
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 5e0710b..ffb0063 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py
@@ -554,8 +554,13 @@ raise EnvironmentException(m) cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler linker = guess_win_linker(env, ['link'], cls, for_machine) + # As of this writing, CCache does not support MSVC but sccache does. + if 'sccache' in ccache: + final_compiler = ccache + compiler + else: + final_compiler = compiler return cls( - compiler, version, for_machine, is_cross, info, target, + final_compiler, version, for_machine, is_cross, info, target, exe_wrap, full_version=cl_signature, linker=linker) if 'PGI Compilers' in out: cls = PGICCompiler if lang == 'c' else PGICPPCompiler
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 307aac3..2a112df 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py
@@ -385,6 +385,14 @@ return [] return ['ccache'] + @staticmethod + def detect_sccache() -> T.List[str]: + try: + subprocess.check_call(['sccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except (OSError, subprocess.CalledProcessError): + return [] + return ['sccache'] + @classmethod def parse_entry(cls, entry: T.Union[str, T.List[str]]) -> T.Tuple[T.List[str], T.List[str]]: compiler = mesonlib.stringlistify(entry) @@ -392,6 +400,9 @@ if compiler[0] == 'ccache': compiler = compiler[1:] ccache = cls.detect_ccache() + elif compiler[0] == 'sccache': + compiler = compiler[1:] + ccache = cls.detect_sccache() else: ccache = [] # Return value has to be a list of compiler 'choices'