aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-12-08 10:33:11 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-01-11 11:15:06 -0800
commit4580433b8255b9f69dfbd39a28c21bc1ec785bcf (patch)
tree57dd738f1d2ebe943f4ae1266d6f8551d737535f /mesonbuild/compilers/compilers.py
parent7248a64750fc0748f7d86b65e03172f00b515690 (diff)
downloadmeson-4580433b8255b9f69dfbd39a28c21bc1ec785bcf.zip
meson-4580433b8255b9f69dfbd39a28c21bc1ec785bcf.tar.gz
meson-4580433b8255b9f69dfbd39a28c21bc1ec785bcf.tar.bz2
rename cflags_mapping to CFLAGS_MAPPING
This is PEP8 convention for a const variable. Also, make the type Mapping, which doesn't have mutation methods. This means mypy will warn us if someone tries to change this.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 234ce06..41e1036 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -91,18 +91,22 @@ languages_using_cppflags = {'c', 'cpp', 'objc', 'objcpp'} # type: T.Set[str]
soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$')
# Environment variables that each lang uses.
-cflags_mapping = {'c': 'CFLAGS',
- 'cpp': 'CXXFLAGS',
- 'cuda': 'CUFLAGS',
- 'objc': 'OBJCFLAGS',
- 'objcpp': 'OBJCXXFLAGS',
- 'fortran': 'FFLAGS',
- 'd': 'DFLAGS',
- 'vala': 'VALAFLAGS',
- 'rust': 'RUSTFLAGS'} # type: T.Dict[str, str]
-
-cexe_mapping = {'c': 'CC',
- 'cpp': 'CXX'}
+CFLAGS_MAPPING: T.Mapping[str, str] = {
+ 'c': 'CFLAGS',
+ 'cpp': 'CXXFLAGS',
+ 'cuda': 'CUFLAGS',
+ 'objc': 'OBJCFLAGS',
+ 'objcpp': 'OBJCXXFLAGS',
+ 'fortran': 'FFLAGS',
+ 'd': 'DFLAGS',
+ 'vala': 'VALAFLAGS',
+ 'rust': 'RUSTFLAGS',
+}
+
+CEXE_MAPPING: T.Mapping = {
+ 'c': 'CC',
+ 'cpp': 'CXX',
+}
# All these are only for C-linkable languages; see `clink_langs` above.
@@ -1207,13 +1211,13 @@ def get_args_from_envvars(lang: str,
Returns a tuple of (compile_flags, link_flags) for the specified language
from the inherited environment
"""
- if lang not in cflags_mapping:
+ if lang not in CFLAGS_MAPPING:
return [], []
compile_flags = [] # type: T.List[str]
link_flags = [] # type: T.List[str]
- env_compile_flags = get_env_var(for_machine, is_cross, cflags_mapping[lang])
+ env_compile_flags = get_env_var(for_machine, is_cross, CFLAGS_MAPPING[lang])
if env_compile_flags is not None:
compile_flags += split_args(env_compile_flags)