diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2020-03-13 13:50:33 +0000 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2020-09-08 18:01:41 +0100 |
commit | f94e1eed97930a5cae6371b20013f55af6d1ab94 (patch) | |
tree | be0ab6c7194957d26eb9ae70d92d0831e20a8f0f /mesonbuild/ast/introspection.py | |
parent | eca4c6fcaf7393a4a042ca2c6d104e83e0de2ffe (diff) | |
download | meson-f94e1eed97930a5cae6371b20013f55af6d1ab94.zip meson-f94e1eed97930a5cae6371b20013f55af6d1ab94.tar.gz meson-f94e1eed97930a5cae6371b20013f55af6d1ab94.tar.bz2 |
Factor out an _add_languages() function in introspector
Factor out an _add_languages() function in introspector, rather than
calling func_add_languages() with arguments crafted to fake an
interpreter call.
Diffstat (limited to 'mesonbuild/ast/introspection.py')
-rw-r--r-- | mesonbuild/ast/introspection.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 6e6927f..8a8de01 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -123,7 +123,8 @@ class IntrospectionInterpreter(AstInterpreter): options = {k: v for k, v in self.environment.meson_options.host[''].items() if k.startswith('backend_')} self.coredata.set_options(options) - self.func_add_languages(None, proj_langs, None) + self._add_languages(proj_langs, MachineChoice.HOST) + self._add_languages(proj_langs, MachineChoice.BUILD) def do_subproject(self, dirname: str) -> None: subproject_dir_abs = os.path.join(self.environment.get_source_dir(), self.subproject_dir) @@ -137,17 +138,20 @@ class IntrospectionInterpreter(AstInterpreter): return def func_add_languages(self, node: BaseNode, args: T.List[TYPE_nvar], kwargs: T.Dict[str, TYPE_nvar]) -> None: - args = self.flatten_args(args) for for_machine in [MachineChoice.BUILD, MachineChoice.HOST]: - for lang in sorted(args, key=compilers.sort_clink): - if isinstance(lang, StringNode): - assert isinstance(lang.value, str) - lang = lang.value - if not isinstance(lang, str): - continue - lang = lang.lower() - if lang not in self.coredata.compilers[for_machine]: - self.environment.detect_compiler_for(lang, for_machine) + self._add_languages(args, for_machine) + + def _add_languages(self, langs: T.List[TYPE_nvar], for_machine: MachineChoice) -> None: + langs = self.flatten_args(langs) + for lang in sorted(langs, key=compilers.sort_clink): + if isinstance(lang, StringNode): + assert isinstance(lang.value, str) + lang = lang.value + if not isinstance(lang, str): + continue + lang = lang.lower() + if lang not in self.coredata.compilers[for_machine]: + self.environment.detect_compiler_for(lang, for_machine) def func_dependency(self, node: BaseNode, args: T.List[TYPE_nvar], kwargs: T.Dict[str, TYPE_nvar]) -> None: args = self.flatten_args(args) |