summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/envconfig.py13
-rw-r--r--unittests/failuretests.py5
2 files changed, 13 insertions, 5 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
index 86bad9be2..c99ae4b01 100644
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -438,16 +438,19 @@ class BinaryTable:
@classmethod
def parse_entry(cls, entry: T.Union[str, T.List[str]]) -> T.Tuple[T.List[str], T.List[str]]:
- compiler = mesonlib.stringlistify(entry)
+ parts = mesonlib.stringlistify(entry)
# Ensure ccache exists and remove it if it doesn't
- if compiler[0] == 'ccache':
- compiler = compiler[1:]
+ if parts[0] == 'ccache':
+ compiler = parts[1:]
ccache = cls.detect_ccache()
- elif compiler[0] == 'sccache':
- compiler = compiler[1:]
+ elif parts[0] == 'sccache':
+ compiler = parts[1:]
ccache = cls.detect_sccache()
else:
+ compiler = parts
ccache = []
+ if not compiler:
+ raise EnvironmentException(f'Compiler cache specified without compiler: {parts[0]}')
# Return value has to be a list of compiler 'choices'
return compiler, ccache
diff --git a/unittests/failuretests.py b/unittests/failuretests.py
index 8a802120b..e5a3b35ea 100644
--- a/unittests/failuretests.py
+++ b/unittests/failuretests.py
@@ -381,3 +381,8 @@ class FailureTests(BasePlatformTests):
def test_error_func(self):
self.assertMesonRaises("error('a', 'b', ['c', ['d', {'e': 'f'}]], 'g')",
r"Problem encountered: a b \['c', \['d', {'e' : 'f'}\]\] g")
+
+ def test_compiler_cache_without_compiler(self):
+ self.assertMesonRaises('',
+ 'Compiler cache specified without compiler: ccache',
+ override_envvars={'CC': 'ccache'})