From c62989ce80c562c655795ffc6fc799b9a048dc59 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 22 Feb 2023 13:30:58 -0800 Subject: rust: add support for b_ndebug Rust has a `debug_assert!()` macro, which is designed to be toggled on the command line. It is on by default in debug builds, and off by default in release builds, in cargo. This matches what meson's b_ndebug option does in `if-release` mode. --- mesonbuild/compilers/rust.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mesonbuild/compilers') diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 1c43f7a..3f353e2 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -63,7 +63,7 @@ class RustCompiler(Compiler): is_cross=is_cross, full_version=full_version, linker=linker) self.exe_wrapper = exe_wrapper - self.base_options.add(OptionKey('b_colorout')) + self.base_options.update({OptionKey(o) for o in ['b_colorout', 'b_ndebug']}) if 'link' in self.linker.id: self.base_options.add(OptionKey('b_vscrt')) @@ -204,6 +204,10 @@ class RustCompiler(Compiler): # pic is on by rustc return [] + def get_assert_args(self, disable: bool) -> T.List[str]: + action = "no" if disable else "yes" + return ['-C', f'debug-assertions={action}'] + class ClippyRustCompiler(RustCompiler): -- cgit v1.1