Skip to content

Commit

Permalink
compilers: make lang_map public
Browse files Browse the repository at this point in the history
Signed-off-by: Sam James <sam@gentoo.org>
  • Loading branch information
thesamesam committed Jun 23, 2024
1 parent 09f3d1f commit 23f87bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions mesonbuild/compilers/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}')
p, output, error = Popen_safe(compiler + args, write='', stdin=subprocess.PIPE)
Expand All @@ -1354,7 +1354,7 @@ def _try_obtain_compiler_defines(args: T.List[str]) -> str:

# 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
Expand Down Expand Up @@ -1385,7 +1385,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)}')
Expand All @@ -1406,7 +1406,7 @@ def _try_obtain_compiler_defines(args: T.List[str]) -> 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
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/compilers/mixins/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
's': ['-Oz'],
}

_LANG_MAP = {
clang_lang_map = {
'c': 'c',
'cpp': 'c++',
'objc': 'objective-c',
Expand Down
8 changes: 4 additions & 4 deletions mesonbuild/compilers/mixins/gnu.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
],
}

_LANG_MAP = {
gnu_lang_map = {
'c': 'c',
'cpp': 'c++',
'objc': 'objective-c',
Expand All @@ -318,9 +318,9 @@

@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', '-']
Expand Down Expand Up @@ -534,7 +534,7 @@ def get_preprocess_to_file_args(self) -> T.List[str]:
# 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}']


Expand Down

0 comments on commit 23f87bc

Please sign in to comment.