From 2a9f40ff7a795dd0c36f8acd61757e32e3c41f48 Mon Sep 17 00:00:00 2001 From: Sam James Date: Mon, 24 Jun 2024 00:32:02 +0100 Subject: compilers: make lang_map public --- mesonbuild/compilers/detect.py | 8 ++++---- mesonbuild/compilers/mixins/clang.py | 2 +- mesonbuild/compilers/mixins/gnu.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 255812c..3a67821 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -1333,7 +1333,7 @@ def _get_gnu_compiler_defines(compiler: T.List[str], lang: str) -> T.Dict[str, s """ Get the list of GCC pre-processor defines """ - from .mixins.gnu import _LANG_MAP as gnu_LANG_MAP + from .mixins.gnu import gnu_lang_map def _try_obtain_compiler_defines(args: T.List[str]) -> str: mlog.debug(f'Running command: {join_args(args)}') @@ -1355,7 +1355,7 @@ def _get_gnu_compiler_defines(compiler: T.List[str], lang: str) -> T.Dict[str, s # We might not have a match for Fortran, so fallback to detection # based on the driver. - lang = gnu_LANG_MAP[lang] + lang = gnu_lang_map[lang] # The compiler may not infer the target language based on the driver name # so first, try with '-cpp -x lang', then fallback without given it's less @@ -1386,7 +1386,7 @@ def _get_clang_compiler_defines(compiler: T.List[str], lang: str) -> T.Dict[str, """ Get the list of Clang pre-processor defines """ - from .mixins.clang import _LANG_MAP as clang_LANG_MAP + from .mixins.clang import clang_lang_map def _try_obtain_compiler_defines(args: T.List[str]) -> str: mlog.debug(f'Running command: {join_args(args)}') @@ -1407,7 +1407,7 @@ def _get_clang_compiler_defines(compiler: T.List[str], lang: str) -> T.Dict[str, # We might not have a match for Fortran, so fallback to detection # based on the driver. - lang = clang_LANG_MAP[lang] + lang = clang_lang_map[lang] # The compiler may not infer the target language based on the driver name # so first, try with '-cpp -x lang', then fallback without given it's less diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py index de9d8f8..e9e83f2 100644 --- a/mesonbuild/compilers/mixins/clang.py +++ b/mesonbuild/compilers/mixins/clang.py @@ -36,7 +36,7 @@ clang_optimization_args: T.Dict[str, T.List[str]] = { 's': ['-Oz'], } -_LANG_MAP = { +clang_lang_map = { 'c': 'c', 'cpp': 'c++', 'objc': 'objective-c', diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 79f2716..587b0cc 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -309,7 +309,7 @@ gnu_objc_warning_args: T.Dict[str, T.List[str]] = { ], } -_LANG_MAP = { +gnu_lang_map = { 'c': 'c', 'cpp': 'c++', 'objc': 'objective-c', @@ -318,9 +318,9 @@ _LANG_MAP = { @functools.lru_cache(maxsize=None) def gnulike_default_include_dirs(compiler: T.Tuple[str, ...], lang: str) -> 'ImmutableListProtocol[str]': - if lang not in _LANG_MAP: + if lang not in gnu_lang_map: return [] - lang = _LANG_MAP[lang] + lang = gnu_lang_map[lang] env = os.environ.copy() env["LC_ALL"] = 'C' cmd = list(compiler) + [f'-x{lang}', '-E', '-v', '-'] @@ -534,7 +534,7 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta): # We want to allow preprocessing files with any extension, such as # foo.c.in. In that case we need to tell GCC/CLANG to treat them as # assembly file. - lang = _LANG_MAP.get(self.language, 'assembler-with-cpp') + lang = gnu_lang_map.get(self.language, 'assembler-with-cpp') return self.get_preprocess_only_args() + [f'-x{lang}'] -- cgit v1.1