aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-02-22 13:30:58 -0800
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2023-04-21 15:18:56 +0530
commitc62989ce80c562c655795ffc6fc799b9a048dc59 (patch)
tree657bc94a2d4c2061c35a16e506c0c59309807692 /mesonbuild/compilers
parentf80f40fa4feb0fa3f365f3debcbe2a43d7d125af (diff)
downloadmeson-c62989ce80c562c655795ffc6fc799b9a048dc59.zip
meson-c62989ce80c562c655795ffc6fc799b9a048dc59.tar.gz
meson-c62989ce80c562c655795ffc6fc799b9a048dc59.tar.bz2
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.
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/rust.py6
1 files changed, 5 insertions, 1 deletions
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):