[glib: 1/3] meson: Fix check for builtype arguments



commit e7cfe62e7383c332355fc71ff0f63d23c8149d60
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Thu Mar 5 00:36:50 2020 +0530

    meson: Fix check for builtype arguments
    
    `get_option('buildtype')` will return `'custom'` for most combinations
    of `-Doptimization` and `-Ddebug`, but those two will always be set
    correctly if only `-Dbuildtype` is set. So we should look at those
    options directly.
    
    For the two-way mapping between `buildtype` and `optimization`
    + `debug`, see this table:
    https://mesonbuild.com/Builtin-options.html#build-type-options

 meson.build | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 36be4ab05..ab4d487ba 100644
--- a/meson.build
+++ b/meson.build
@@ -214,11 +214,15 @@ glibconfig_conf.set('glib_os', glib_os)
 # for dependencies that don't normally come with pkg-config files for Visual Studio builds
 buildtype = get_option('buildtype')
 
+# Use debug/optimization flags to determine whether to enable debug or disable
+# cast checks
 glib_debug_cflags = []
-if buildtype.startswith('debug')
+if get_option('debug')
   glib_debug_cflags += ['-DG_ENABLE_DEBUG']
-elif buildtype == 'release'
+  message('Enabling various debug infrastructure')
+elif get_option('optimization') in ['2', '3', 's']
   glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS']
+  message('Disabling cast checks')
 endif
 
 add_project_arguments(glib_debug_cflags, language: 'c')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]