Directly pass the compiler to get_args_from_envvars

Seems better to do this since the behaviour is compiler-specific. Would
be easier to extend this later too in case we want to do more
compiler-specific things.
pull/949/head
Nirbheek Chauhan 8 years ago
parent 4be8e71fb3
commit 3df75d696d
  1. 12
      mesonbuild/environment.py
  2. 5
      mesonbuild/interpreter.py

@ -833,9 +833,9 @@ class Environment():
return self.coredata.get_builtin_option('datadir')
def get_args_from_envvars(lang, compiler_is_linker):
def get_args_from_envvars(compiler):
"""
@lang: Language to fetch environment flags for
@compiler: Compiler to fetch environment flags for
Returns a tuple of (compile_flags, link_flags) for the specified language
from the inherited environment
@ -844,14 +844,18 @@ def get_args_from_envvars(lang, compiler_is_linker):
if val:
mlog.log('Appending {} from environment: {!r}'.format(var, val))
lang = compiler.get_language()
compiler_is_linker = False
if hasattr(compiler, 'get_linker_exelist'):
compiler_is_linker = (compiler.get_exelist() == compiler.get_linker_exelist())
if lang not in ('c', 'cpp', 'objc', 'objcpp', 'fortran', 'd'):
return ([], [])
# Compile flags
cflags_mapping = {'c': 'CFLAGS', 'cpp': 'CXXFLAGS',
'objc': 'OBJCFLAGS', 'objcpp': 'OBJCXXFLAGS',
'fortran': 'FFLAGS',
'd': 'DFLAGS'}
'fortran': 'FFLAGS', 'd': 'DFLAGS'}
compile_flags = os.environ.get(cflags_mapping[lang], '')
log_var(cflags_mapping[lang], compile_flags)
compile_flags = compile_flags.split()

@ -1792,11 +1792,8 @@ class Interpreter():
else:
raise
mlog.log('Native %s compiler: ' % lang, mlog.bold(' '.join(comp.get_exelist())), ' (%s %s)' % (comp.id, comp.version), sep='')
compiler_is_linker = False
if hasattr(comp, 'get_linker_exelist'):
compiler_is_linker = (comp.get_exelist() == comp.get_linker_exelist())
if not comp.get_language() in self.coredata.external_args:
(ext_compile_args, ext_link_args) = environment.get_args_from_envvars(comp.get_language(), compiler_is_linker)
(ext_compile_args, ext_link_args) = environment.get_args_from_envvars(comp)
self.coredata.external_args[comp.get_language()] = ext_compile_args
self.coredata.external_link_args[comp.get_language()] = ext_link_args
self.build.add_compiler(comp)

Loading…
Cancel
Save