From a859d76c728814dbf58281f51e4cd0d8d7b1fece Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sun, 17 Mar 2019 14:35:56 +0100 Subject: [PATCH] meson: Cleanup debug build handling Add debug flags based on meson's `debug` option instead of `buildtype`. This allows custom build configurations to behave like a debug or release build. Add `-fno-omit-frame-pointer` to Mutter/Cogl. Not to Clutter though, as that would require more changes to how Clutter's gir is created Remove `-DG_DISABLE_CAST_CHECKS` from Clutter in debug builds Add `-DG_DISABLE_CHECKS`, `-DG_DISABLE_ASSERT` and `-DG_DISABLE_CAST_CHECKS` to all non-debug builds but `plain`, which explicitly should not have any compile flags Use `cc.get_supported_arguments`, so it becomes more obvious to the user which flags are set during compilation https://gitlab.gnome.org/GNOME/mutter/merge_requests/497 --- clutter/meson.build | 13 ++++++------- cogl/meson.build | 10 ++++++---- meson.build | 12 +++++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/clutter/meson.build b/clutter/meson.build index ab34c74c4..c914a2284 100644 --- a/clutter/meson.build +++ b/clutter/meson.build @@ -12,19 +12,18 @@ clutter_c_args = [ ] clutter_debug_c_args = [] -if buildtype.startswith('debug') - clutter_debug_c_args += '-DG_DISABLE_CAST_CHECKS' - if buildtype == 'debug' - clutter_debug_c_args += '-DCLUTTER_ENABLE_DEBUG' - endif -elif buildtype == 'release' +if get_option('debug') + clutter_debug_c_args += [ + '-DCLUTTER_ENABLE_DEBUG' + ] +elif buildtype != 'plain' clutter_debug_c_args += [ '-DG_DISABLE_ASSERT', '-DG_DISABLE_CHECKS', '-DG_DISABLE_CAST_CHECKS', ] endif - +supported_clutter_debug_c_args = cc.get_supported_arguments(clutter_debug_c_args) clutter_c_args += clutter_debug_c_args clutter_pkg_deps = [ diff --git a/cogl/meson.build b/cogl/meson.build index 30e241438..585e71697 100644 --- a/cogl/meson.build +++ b/cogl/meson.build @@ -87,19 +87,21 @@ if have_gles2 endif cogl_debug_c_args = [] -if buildtype.startswith('debug') +buildtype = get_option('buildtype') +if get_option('debug') cogl_debug_c_args += [ '-DCOGL_GL_DEBUG', '-DCOGL_OBJECT_DEBUG', '-DCOGL_ENABLE_DEBUG', + '-fno-omit-frame-pointer' ] -elif buildtype == 'release' +elif buildtype != 'plain' cogl_debug_c_args += [ '-DG_DISABLE_CHECKS', - '-DG_DISABLE_CAST_CHECKS', + '-DG_DISABLE_CAST_CHECKS' ] endif - +supported_cogl_debug_c_args = cc.get_supported_arguments(cogl_debug_c_args) cogl_c_args += cogl_debug_c_args if have_cogl_tests diff --git a/meson.build b/meson.build index 08b9ba73a..961c47f8b 100644 --- a/meson.build +++ b/meson.build @@ -318,12 +318,14 @@ supported_warnings = cc.get_supported_arguments(all_warnings) add_project_arguments(supported_warnings, language: 'c') -debug_c_args = [] -buildtype = get_option('buildtype') -if buildtype.startswith('debug') - debug_c_args += '-DG_ENABLE_DEBUG' +if get_option('debug') + debug_c_args = [ + '-DG_ENABLE_DEBUG', + '-fno-omit-frame-pointer' + ] + supported_debug_c_args = cc.get_supported_arguments(debug_c_args) + add_project_arguments(supported_debug_c_args, language: 'c') endif -add_project_arguments(debug_c_args, language: 'c') cc.compiles('void main (void) { __builtin_ffsl (0); __builtin_popcountl (0); }')