Fix b_ndebug=if-release option

Provide get_{type}_options_for_target() methods that unite {type} and builtin options.
pull/3286/head
Aleksey Filippov 7 years ago committed by Nirbheek Chauhan
parent 17c402f708
commit 6795b619c6
  1. 25
      mesonbuild/backend/backends.py
  2. 3
      mesonbuild/backend/ninjabackend.py
  3. 4
      mesonbuild/compilers/compilers.py

@ -89,12 +89,17 @@ class OptionProxy:
class OptionOverrideProxy:
'''Mimic an option list but transparently override
selected option values.'''
def __init__(self, overrides, options):
def __init__(self, overrides, *options):
self.overrides = overrides
self.options = options
def __getitem__(self, option_name):
base_opt = self.options[option_name]
for opts in self.options:
if option_name in opts:
return self._get_override(option_name, opts[option_name])
raise KeyError('Option not found', option_name)
def _get_override(self, option_name, base_opt):
if option_name in self.overrides:
return OptionProxy(base_opt.name, base_opt.validate_value(self.overrides[option_name]))
return base_opt
@ -126,6 +131,20 @@ class Backend:
def get_target_filename_abs(self, target):
return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))
def get_builtin_options_for_target(self, target):
return OptionOverrideProxy(target.option_overrides,
self.environment.coredata.builtins)
def get_base_options_for_target(self, target):
return OptionOverrideProxy(target.option_overrides,
self.environment.coredata.builtins,
self.environment.coredata.base_options)
def get_compiler_options_for_target(self, target):
return OptionOverrideProxy(target.option_overrides,
# no code depends on builtins for now
self.environment.coredata.compiler_options)
def get_option_for_target(self, option_name, target):
if option_name in target.option_overrides:
override = target.option_overrides[option_name]
@ -449,7 +468,7 @@ class Backend:
# starting from hard-coded defaults followed by build options and so on.
commands = CompilerArgs(compiler)
copt_proxy = OptionOverrideProxy(target.option_overrides, self.environment.coredata.compiler_options)
copt_proxy = self.get_compiler_options_for_target(target)
# First, the trivial ones that are impossible to override.
#
# Add -nostdinc/-nostdinc++ if needed; can't be overridden

@ -2101,8 +2101,7 @@ rule FORTRAN_DEP_HACK
return incs
def _generate_single_compile(self, target, compiler, is_generated=False):
base_proxy = backends.OptionOverrideProxy(target.option_overrides,
self.environment.coredata.base_options)
base_proxy = self.get_base_options_for_target(target)
# Create an empty commands list, and start adding arguments from
# various sources in the order in which they must override each other
commands = CompilerArgs(compiler)

@ -315,7 +315,9 @@ def get_base_compile_args(options, compiler):
except KeyError:
pass
try:
if options['b_ndebug'].value == 'true' or (options['b_ndebug'].value == 'if-release' and options['buildtype'] == 'release'):
if (options['b_ndebug'].value == 'true' or
(options['b_ndebug'].value == 'if-release' and
options['buildtype'].value == 'release')):
args += ['-DNDEBUG']
except KeyError:
pass

Loading…
Cancel
Save