aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/envconfig.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-10-22 16:59:34 +0300
committerXavier Claessens <xclaesse@gmail.com>2021-10-25 19:59:49 -0400
commit4840c86ec94b0d34a443d38ac771f1e7fe000c59 (patch)
treebeb52df91153e8b67557ab30ba2fc93187bb1298 /mesonbuild/envconfig.py
parentabaa980436f53100041bd5535589bb1c42019bd6 (diff)
downloadmeson-4840c86ec94b0d34a443d38ac771f1e7fe000c59.zip
meson-4840c86ec94b0d34a443d38ac771f1e7fe000c59.tar.gz
meson-4840c86ec94b0d34a443d38ac771f1e7fe000c59.tar.bz2
Add sccache support.
Diffstat (limited to 'mesonbuild/envconfig.py')
-rw-r--r--mesonbuild/envconfig.py19
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'