Fix b_ndebug=if-release option

Provide get_{type}_options_for_target() methods that unite {type} and builtin options.
pull/3274/head
Aleksey Filippov 7 years ago
parent af0b569ced
commit 2febb99eee
  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: class OptionOverrideProxy:
'''Mimic an option list but transparently override '''Mimic an option list but transparently override
selected option values.''' selected option values.'''
def __init__(self, overrides, options): def __init__(self, overrides, *options):
self.overrides = overrides self.overrides = overrides
self.options = options self.options = options
def __getitem__(self, option_name): 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: if option_name in self.overrides:
return OptionProxy(base_opt.name, base_opt.validate_value(self.overrides[option_name])) return OptionProxy(base_opt.name, base_opt.validate_value(self.overrides[option_name]))
return base_opt return base_opt
@ -123,6 +128,20 @@ class Backend:
def get_target_filename_abs(self, target): def get_target_filename_abs(self, target):
return os.path.join(self.environment.get_build_dir(), self.get_target_filename(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): def get_option_for_target(self, option_name, target):
if option_name in target.option_overrides: if option_name in target.option_overrides:
override = target.option_overrides[option_name] override = target.option_overrides[option_name]
@ -444,7 +463,7 @@ class Backend:
# starting from hard-coded defaults followed by build options and so on. # starting from hard-coded defaults followed by build options and so on.
commands = CompilerArgs(compiler) 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. # First, the trivial ones that are impossible to override.
# #
# Add -nostdinc/-nostdinc++ if needed; can't be overridden # Add -nostdinc/-nostdinc++ if needed; can't be overridden

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

@ -315,7 +315,9 @@ def get_base_compile_args(options, compiler):
except KeyError: except KeyError:
pass pass
try: 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'] args += ['-DNDEBUG']
except KeyError: except KeyError:
pass pass

Loading…
Cancel
Save