diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2023-02-22 13:10:24 -0800 |
|---|---|---|
| committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2023-04-21 15:18:56 +0530 |
| commit | bfce5c45a4784d86be8472a00f628f2ffac74cf2 (patch) | |
| tree | 420ebb65147f91175e9b84bc9dbb50cbf20b8684 /mesonbuild/compilers/d.py | |
| parent | c0c9f755a40a51889e73275578cb49296de84e43 (diff) | |
| download | meson-bfce5c45a4784d86be8472a00f628f2ffac74cf2.tar.gz | |
compilers: convert method to get assert control to a boolean
C like compilers only off `-DNDEBUG` to disable asserts. This is not a
universal paradigm however. Rust, for example has an argument that takes
a boolean. To better represent this, we allow passing a `disable`
boolean. `disable` was chosen rather than `enable` because it allowed
all existing logic to be left in place
Diffstat (limited to 'mesonbuild/compilers/d.py')
| -rw-r--r-- | mesonbuild/compilers/d.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 5d43a6011..4cdda0093 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -855,8 +855,10 @@ class GnuDCompiler(GnuCompiler, DCompiler): return args return args + ['-shared-libphobos'] - def get_disable_assert_args(self) -> T.List[str]: - return ['-frelease'] + def get_assert_args(self, disable: bool) -> T.List[str]: + if disable: + return ['-frelease'] + return [] # LDC uses the DMD frontend code to parse and analyse the code. # It then uses LLVM for the binary code generation and optimizations. @@ -927,8 +929,10 @@ class LLVMDCompiler(DmdLikeCompilerMixin, DCompiler): return args return args + ['-link-defaultlib-shared'] - def get_disable_assert_args(self) -> T.List[str]: - return ['--release'] + def get_assert_args(self, disable: bool) -> T.List[str]: + if disable: + return ['--release'] + return [] def rsp_file_syntax(self) -> RSPFileSyntax: # We use `mesonlib.is_windows` here because we want to know what the @@ -1015,8 +1019,10 @@ class DmdDCompiler(DmdLikeCompilerMixin, DCompiler): return args return args + ['-defaultlib=phobos2', '-debuglib=phobos2'] - def get_disable_assert_args(self) -> T.List[str]: - return ['-release'] + def get_assert_args(self, disable: bool) -> T.List[str]: + if disable: + return ['-release'] + return [] def rsp_file_syntax(self) -> RSPFileSyntax: return RSPFileSyntax.MSVC |
