diff options
Diffstat (limited to 'mesonbuild/envconfig.py')
-rw-r--r-- | mesonbuild/envconfig.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 307aac3..2af45bf 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -385,6 +385,22 @@ class BinaryTable: 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'] + + @staticmethod + def detect_compiler_cache() -> T.List[str]: + # Sccache is "newer" so it is assumed that people would prefer it by default. + cache = BinaryTable.detect_sccache() + if cache: + return cache + return BinaryTable.detect_ccache() + @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 +408,9 @@ class BinaryTable: 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' |