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.
This commit is contained in:
parent
7248a64750
commit
4580433b82
|
@ -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]+)?$')
|
soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$')
|
||||||
|
|
||||||
# Environment variables that each lang uses.
|
# Environment variables that each lang uses.
|
||||||
cflags_mapping = {'c': 'CFLAGS',
|
CFLAGS_MAPPING: T.Mapping[str, str] = {
|
||||||
'cpp': 'CXXFLAGS',
|
'c': 'CFLAGS',
|
||||||
'cuda': 'CUFLAGS',
|
'cpp': 'CXXFLAGS',
|
||||||
'objc': 'OBJCFLAGS',
|
'cuda': 'CUFLAGS',
|
||||||
'objcpp': 'OBJCXXFLAGS',
|
'objc': 'OBJCFLAGS',
|
||||||
'fortran': 'FFLAGS',
|
'objcpp': 'OBJCXXFLAGS',
|
||||||
'd': 'DFLAGS',
|
'fortran': 'FFLAGS',
|
||||||
'vala': 'VALAFLAGS',
|
'd': 'DFLAGS',
|
||||||
'rust': 'RUSTFLAGS'} # type: T.Dict[str, str]
|
'vala': 'VALAFLAGS',
|
||||||
|
'rust': 'RUSTFLAGS',
|
||||||
|
}
|
||||||
|
|
||||||
cexe_mapping = {'c': 'CC',
|
CEXE_MAPPING: T.Mapping = {
|
||||||
'cpp': 'CXX'}
|
'c': 'CC',
|
||||||
|
'cpp': 'CXX',
|
||||||
|
}
|
||||||
|
|
||||||
# All these are only for C-linkable languages; see `clink_langs` above.
|
# 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
|
Returns a tuple of (compile_flags, link_flags) for the specified language
|
||||||
from the inherited environment
|
from the inherited environment
|
||||||
"""
|
"""
|
||||||
if lang not in cflags_mapping:
|
if lang not in CFLAGS_MAPPING:
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
compile_flags = [] # type: T.List[str]
|
compile_flags = [] # type: T.List[str]
|
||||||
link_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:
|
if env_compile_flags is not None:
|
||||||
compile_flags += split_args(env_compile_flags)
|
compile_flags += split_args(env_compile_flags)
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ from ..mesonlib import (MesonException, Popen_safe, MachineChoice,
|
||||||
from ..interpreterbase import InterpreterObject, InterpreterException, FeatureNew
|
from ..interpreterbase import InterpreterObject, InterpreterException, FeatureNew
|
||||||
from ..interpreterbase import stringArgs, permittedKwargs
|
from ..interpreterbase import stringArgs, permittedKwargs
|
||||||
from ..interpreter import Interpreter, DependencyHolder, InstallDir
|
from ..interpreter import Interpreter, DependencyHolder, InstallDir
|
||||||
from ..compilers.compilers import cflags_mapping, cexe_mapping
|
from ..compilers.compilers import CFLAGS_MAPPING, CEXE_MAPPING
|
||||||
from ..dependencies.base import InternalDependency, PkgConfigDependency
|
from ..dependencies.base import InternalDependency, PkgConfigDependency
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..mesonlib import OptionKey
|
from ..mesonlib import OptionKey
|
||||||
|
@ -110,11 +110,11 @@ class ExternalProject(InterpreterObject):
|
||||||
link_args = []
|
link_args = []
|
||||||
self.run_env = os.environ.copy()
|
self.run_env = os.environ.copy()
|
||||||
for lang, compiler in self.env.coredata.compilers[MachineChoice.HOST].items():
|
for lang, compiler in self.env.coredata.compilers[MachineChoice.HOST].items():
|
||||||
if any(lang not in i for i in (cexe_mapping, cflags_mapping)):
|
if any(lang not in i for i in (CEXE_MAPPING, CFLAGS_MAPPING)):
|
||||||
continue
|
continue
|
||||||
cargs = self.env.coredata.get_external_args(MachineChoice.HOST, lang)
|
cargs = self.env.coredata.get_external_args(MachineChoice.HOST, lang)
|
||||||
self.run_env[cexe_mapping[lang]] = self._quote_and_join(compiler.get_exelist())
|
self.run_env[CEXE_MAPPING[lang]] = self._quote_and_join(compiler.get_exelist())
|
||||||
self.run_env[cflags_mapping[lang]] = self._quote_and_join(cargs)
|
self.run_env[CFLAGS_MAPPING[lang]] = self._quote_and_join(cargs)
|
||||||
if not link_exelist:
|
if not link_exelist:
|
||||||
link_exelist = compiler.get_linker_exelist()
|
link_exelist = compiler.get_linker_exelist()
|
||||||
link_args = self.env.coredata.get_external_link_args(MachineChoice.HOST, lang)
|
link_args = self.env.coredata.get_external_link_args(MachineChoice.HOST, lang)
|
||||||
|
|
|
@ -9347,7 +9347,7 @@ def unset_envs():
|
||||||
# For unit tests we must fully control all command lines
|
# For unit tests we must fully control all command lines
|
||||||
# so that there are no unexpected changes coming from the
|
# so that there are no unexpected changes coming from the
|
||||||
# environment, for example when doing a package build.
|
# environment, for example when doing a package build.
|
||||||
varnames = ['CPPFLAGS', 'LDFLAGS'] + list(mesonbuild.compilers.compilers.cflags_mapping.values())
|
varnames = ['CPPFLAGS', 'LDFLAGS'] + list(mesonbuild.compilers.compilers.CFLAGS_MAPPING.values())
|
||||||
for v in varnames:
|
for v in varnames:
|
||||||
if v in os.environ:
|
if v in os.environ:
|
||||||
del os.environ[v]
|
del os.environ[v]
|
||||||
|
|
Loading…
Reference in New Issue