Pass Environment down from Backend

We'll need it in a moment for get_base_compile_args -> get_assert_args.

Bug: https://github.com/mesonbuild/meson/issues/12962
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
pull/13014/head
Sam James 10 months ago committed by Eli Schwartz
parent 31314419aa
commit 5bd28febf7
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 6
      mesonbuild/backend/ninjabackend.py
  2. 2
      mesonbuild/backend/vs2010backend.py
  3. 6
      mesonbuild/compilers/compilers.py
  4. 4
      mesonbuild/compilers/cpp.py
  5. 4
      mesonbuild/compilers/cuda.py
  6. 6
      mesonbuild/compilers/d.py
  7. 2
      mesonbuild/compilers/mixins/clike.py
  8. 2
      mesonbuild/compilers/rust.py

@ -1871,7 +1871,7 @@ class NinjaBackend(backends.Backend):
base_proxy = target.get_options() base_proxy = target.get_options()
args = rustc.compiler_args() args = rustc.compiler_args()
# Compiler args for compiling this target # Compiler args for compiling this target
args += compilers.get_base_compile_args(base_proxy, rustc) args += compilers.get_base_compile_args(base_proxy, rustc, self.environment)
self.generate_generator_list_rules(target) self.generate_generator_list_rules(target)
# dependencies need to cause a relink, they're not just for ordering # dependencies need to cause a relink, they're not just for ordering
@ -2757,7 +2757,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
compiler = get_compiler_for_source(target.compilers.values(), src) compiler = get_compiler_for_source(target.compilers.values(), src)
commands = compiler.compiler_args() commands = compiler.compiler_args()
# Compiler args for compiling this target # Compiler args for compiling this target
commands += compilers.get_base_compile_args(base_proxy, compiler) commands += compilers.get_base_compile_args(base_proxy, compiler, self.environment)
if isinstance(src, File): if isinstance(src, File):
if src.is_built: if src.is_built:
src_filename = os.path.join(src.subdir, src.fname) src_filename = os.path.join(src.subdir, src.fname)
@ -2822,7 +2822,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
# options passed on the command-line, in default_options, etc. # options passed on the command-line, in default_options, etc.
# These have the lowest priority. # These have the lowest priority.
commands += compilers.get_base_compile_args(base_proxy, commands += compilers.get_base_compile_args(base_proxy,
compiler) compiler, self.environment)
return commands return commands
@lru_cache(maxsize=None) @lru_cache(maxsize=None)

@ -984,7 +984,7 @@ class Vs2010Backend(backends.Backend):
for l, comp in target.compilers.items(): for l, comp in target.compilers.items():
if l in file_args: if l in file_args:
file_args[l] += compilers.get_base_compile_args( file_args[l] += compilers.get_base_compile_args(
target.get_options(), comp) target.get_options(), comp, self.environment)
file_args[l] += comp.get_option_compile_args( file_args[l] += comp.get_option_compile_args(
target.get_options()) target.get_options())

@ -283,7 +283,7 @@ def are_asserts_disabled(options: KeyedOptionDictType) -> bool:
options[OptionKey('buildtype')].value in {'release', 'plain'})) options[OptionKey('buildtype')].value in {'release', 'plain'}))
def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler') -> T.List[str]: def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler', env: 'Environment') -> T.List[str]:
args: T.List[str] = [] args: T.List[str] = []
try: try:
if options[OptionKey('b_lto')].value: if options[OptionKey('b_lto')].value:
@ -314,7 +314,7 @@ def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler')
except KeyError: except KeyError:
pass pass
try: try:
args += compiler.get_assert_args(are_asserts_disabled(options)) args += compiler.get_assert_args(are_asserts_disabled(options), env)
except KeyError: except KeyError:
pass pass
# This does not need a try...except # This does not need a try...except
@ -1060,7 +1060,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def get_coverage_link_args(self) -> T.List[str]: def get_coverage_link_args(self) -> T.List[str]:
return self.linker.get_coverage_args() return self.linker.get_coverage_args()
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
"""Get arguments to enable or disable assertion. """Get arguments to enable or disable assertion.
:param disable: Whether to disable assertions :param disable: Whether to disable assertions

@ -307,7 +307,7 @@ class ClangCPPCompiler(_StdCPPLibMixin, ClangCompiler, CPPCompiler):
return libs return libs
return [] return []
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
args: T.List[str] = [] args: T.List[str] = []
if disable: if disable:
return ['-DNDEBUG'] return ['-DNDEBUG']
@ -502,7 +502,7 @@ class GnuCPPCompiler(_StdCPPLibMixin, GnuCompiler, CPPCompiler):
return libs return libs
return [] return []
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
if disable: if disable:
return ['-DNDEBUG'] return ['-DNDEBUG']

@ -802,5 +802,5 @@ class CudaCompiler(Compiler):
def get_profile_use_args(self) -> T.List[str]: def get_profile_use_args(self) -> T.List[str]:
return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_use_args()] return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_use_args()]
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
return self.host_compiler.get_assert_args(disable) return self.host_compiler.get_assert_args(disable, env)

@ -696,7 +696,7 @@ class GnuDCompiler(GnuCompiler, DCompiler):
return args return args
return args + ['-shared-libphobos'] return args + ['-shared-libphobos']
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
if disable: if disable:
return ['-frelease'] return ['-frelease']
return [] return []
@ -766,7 +766,7 @@ class LLVMDCompiler(DmdLikeCompilerMixin, DCompiler):
return args return args
return args + ['-link-defaultlib-shared'] return args + ['-link-defaultlib-shared']
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
if disable: if disable:
return ['--release'] return ['--release']
return [] return []
@ -852,7 +852,7 @@ class DmdDCompiler(DmdLikeCompilerMixin, DCompiler):
return args return args
return args + ['-defaultlib=phobos2', '-debuglib=phobos2'] return args + ['-defaultlib=phobos2', '-debuglib=phobos2']
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
if disable: if disable:
return ['-release'] return ['-release']
return [] return []

@ -1309,7 +1309,7 @@ class CLikeCompiler(Compiler):
return self.compiles(self.attribute_check_func(name), env, return self.compiles(self.attribute_check_func(name), env,
extra_args=self.get_has_func_attribute_extra_args(name)) extra_args=self.get_has_func_attribute_extra_args(name))
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
if disable: if disable:
return ['-DNDEBUG'] return ['-DNDEBUG']
return [] return []

@ -215,7 +215,7 @@ class RustCompiler(Compiler):
# pic is on by rustc # pic is on by rustc
return [] return []
def get_assert_args(self, disable: bool) -> T.List[str]: def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
action = "no" if disable else "yes" action = "no" if disable else "yes"
return ['-C', f'debug-assertions={action}', '-C', 'overflow-checks=no'] return ['-C', f'debug-assertions={action}', '-C', 'overflow-checks=no']

Loading…
Cancel
Save