diff --git a/docs/markdown/Feature-autodetection.md b/docs/markdown/Feature-autodetection.md index 211ba2be0..3dff333de 100644 --- a/docs/markdown/Feature-autodetection.md +++ b/docs/markdown/Feature-autodetection.md @@ -23,6 +23,9 @@ changed). Meson will then use the specified compiler without Ccache. [sccache](https://github.com/mozilla/sccache) is auto-detected the same way, and is preferred over Ccache when both are installed. +[BuildCache](https://gitlab.com/bits-n-bites/buildcache) is +auto-detected as well, after Ccache and sccache. + [kache](https://github.com/kunobi-ninja/kache) is also supported, but is never added automatically: it must be invoked with a compiler subcommand (`kache cc`, `kache c++`, ...), so Meson cannot safely diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index 14f2e4176..f63b5e410 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -181,7 +181,7 @@ pkg-config = '/usr/bin/i586-mingw32msvc-pkg-config' ``` The compiler may be prefixed with a supported compiler cache wrapper, -namely ccache, sccache or kache, e.g. `c = ['kache', 'cc']`. +namely ccache, sccache, kache or buildcache, e.g. `c = ['kache', 'cc']`. An incomplete list of internally used programs that can be overridden here is: diff --git a/docs/markdown/snippets/buildcache.md b/docs/markdown/snippets/buildcache.md new file mode 100644 index 000000000..1a1d3bec0 --- /dev/null +++ b/docs/markdown/snippets/buildcache.md @@ -0,0 +1,7 @@ +## Added support for buildcache + +Meson now recognizes [BuildCache](https://gitlab.com/bits-n-bites/buildcache) +as a compiler wrapper, so setting e.g. `CC="buildcache cc"` works like it +already does for Ccache and sccache. BuildCache is also auto-detected +alongside Ccache and sccache, and is used as a fallback after both of those +when no compiler is specified explicitly. \ No newline at end of file diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index d7aeb25da..19ff0a84d 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -496,13 +496,20 @@ class BinaryTable: def detect_kache() -> ExternalProgram: return ExternalProgram('kache', silent=True) + @staticmethod + def detect_buildcache() -> ExternalProgram: + return ExternalProgram('buildcache', silent=True) + @staticmethod def detect_compiler_cache() -> ExternalProgram: # Sccache is "newer" so it is assumed that people would prefer it by default. cache = BinaryTable.detect_sccache() if cache.found(): return cache - return BinaryTable.detect_ccache() + cache = BinaryTable.detect_ccache() + if cache.found(): + return cache + return BinaryTable.detect_buildcache() @classmethod def parse_entry(cls, entry: T.Union[str, T.List[str]]) -> T.Tuple[T.List[str], T.Union[None, ExternalProgram]]: @@ -517,6 +524,9 @@ class BinaryTable: elif parts[0] == 'kache': compiler = parts[1:] ccache = cls.detect_kache() + elif parts[0] == 'buildcache': + compiler = parts[1:] + ccache = cls.detect_buildcache() else: compiler = parts ccache = None diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index acc78672e..ad4eceaa7 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -1341,7 +1341,7 @@ class AllPlatformTests(BasePlatformTests): for cmd in self.get_compdb(): # Get compiler split = split_args(cmd['command']) - if os.path.basename(split[0]) in ('ccache', 'sccache'): + if os.path.basename(split[0]) in ('ccache', 'sccache', 'buildcache'): compiler = split[1] else: compiler = split[0] diff --git a/unittests/failuretests.py b/unittests/failuretests.py index f40771482..17c4e0f1d 100644 --- a/unittests/failuretests.py +++ b/unittests/failuretests.py @@ -394,3 +394,12 @@ class FailureTests(BasePlatformTests): self.assertMesonRaises('', 'Compiler cache specified without compiler: ccache', override_envvars={'CC': 'ccache'}) + self.assertMesonRaises('', + 'Compiler cache specified without compiler: sccache', + override_envvars={'CC': 'sccache'}) + self.assertMesonRaises('', + 'Compiler cache specified without compiler: kache', + override_envvars={'CC': 'kache'}) + self.assertMesonRaises('', + 'Compiler cache specified without compiler: buildcache', + override_envvars={'CC': 'buildcache'})