From 3037ade41dc0cfc1cb84b0a668784c8d1af46987 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 21 Mar 2019 20:43:54 -0400 Subject: Inline check_compilers This function is used just once. It also seems all policy and no mechanism (it raises, it calls the same function to do all the work twice in a simple way). This makes it seem to be as a good candidate for inlining. `environment` and `coredata` are woefully intertwined and while this change doesn't fix that, but at least it makes it easier to follow. --- mesonbuild/environment.py | 8 -------- mesonbuild/interpreter.py | 6 +++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index d0dccf4..0832463 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -1127,14 +1127,6 @@ class Environment: return comp, cross_comp - def check_compilers(self, lang: str, comp: Compiler, cross_comp: Compiler): - if comp is None: - raise EnvironmentException('Tried to use unknown language "%s".' % lang) - - comp.sanity_check(self.get_scratch_dir(), self) - if cross_comp: - cross_comp.sanity_check(self.get_scratch_dir(), self) - def detect_compilers(self, lang: str, need_cross_compiler: bool): (comp, cross_comp) = self.compilers_from_language(lang, need_cross_compiler) if comp is not None: diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 1e094dd..654f627 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2696,7 +2696,11 @@ external dependencies (including libraries) must go to "dependencies".''') else: try: (comp, cross_comp) = self.environment.detect_compilers(lang, need_cross_compiler) - self.environment.check_compilers(lang, comp, cross_comp) + if comp is None: + raise InvalidArguments('Tried to use unknown language "%s".' % lang) + comp.sanity_check(self.environment.get_scratch_dir(), self.environment) + if cross_comp: + cross_comp.sanity_check(self.environment.get_scratch_dir(), self.environment) except Exception: if not required: mlog.log('Compiler for language', mlog.bold(lang), 'not found.') -- cgit v1.1