From ee65ca791bf8b38b6d536bf2965507bc898e939e Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Tue, 10 Oct 2023 04:14:51 +0200 Subject: [PATCH] build: Harmonize c_args handling The slightly different styles in the different build files make it harder to reason about or share c_args. This notably ensures we never set any extra c_args for plain builds and fixes the cc.get_supported_arguments() check in Cogl, Clutter and Mtk. Part-of: --- clutter/meson.build | 24 +++++++++++++----------- cogl/meson.build | 27 ++++++++++++++------------- meson.build | 21 ++++++++++----------- mtk/meson.build | 22 ++++++++++++---------- 4 files changed, 49 insertions(+), 45 deletions(-) diff --git a/clutter/meson.build b/clutter/meson.build index 9c365b49e..2529a61d4 100644 --- a/clutter/meson.build +++ b/clutter/meson.build @@ -12,18 +12,20 @@ clutter_c_args = [ ] clutter_debug_c_args = [] -if get_option('debug') - clutter_debug_c_args += [ - '-DCLUTTER_ENABLE_DEBUG', - '-fno-omit-frame-pointer' - ] -elif buildtype != 'plain' - clutter_debug_c_args += [ - '-DG_DISABLE_ASSERT', - '-DG_DISABLE_CAST_CHECKS', - ] +if buildtype != 'plain' + if get_option('debug') + clutter_debug_c_args += [ + '-DCLUTTER_ENABLE_DEBUG', + '-fno-omit-frame-pointer', + ] + else + clutter_debug_c_args += [ + '-DG_DISABLE_ASSERT', + '-DG_DISABLE_CAST_CHECKS', + ] + endif endif -supported_clutter_debug_c_args = cc.get_supported_arguments(clutter_debug_c_args) +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 3904e8eba..51f4b1550 100644 --- a/cogl/meson.build +++ b/cogl/meson.build @@ -84,20 +84,21 @@ if have_gles2 endif cogl_debug_c_args = [] -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 != 'plain' - cogl_debug_c_args += [ - '-DG_DISABLE_CAST_CHECKS' - ] +if buildtype != 'plain' + if get_option('debug') + cogl_debug_c_args += [ + '-DCOGL_GL_DEBUG', + '-DCOGL_OBJECT_DEBUG', + '-DCOGL_ENABLE_DEBUG', + '-fno-omit-frame-pointer', + ] + else + cogl_debug_c_args += [ + '-DG_DISABLE_CAST_CHECKS', + ] + endif endif -supported_cogl_debug_c_args = cc.get_supported_arguments(cogl_debug_c_args) +cogl_debug_c_args = cc.get_supported_arguments(cogl_debug_c_args) cogl_c_args += cogl_debug_c_args subdir('cogl') diff --git a/meson.build b/meson.build index 2471f9b7d..1c4bfe15e 100644 --- a/meson.build +++ b/meson.build @@ -466,7 +466,7 @@ add_project_arguments('-D_GNU_SOURCE', language: 'c') buildtype = get_option('buildtype') if buildtype != 'plain' - all_warnings = [ + mutter_c_args = [ '-fno-strict-aliasing', '-Wpointer-arith', '-Wmissing-declarations', @@ -506,17 +506,16 @@ if buildtype != 'plain' '-Wno-missing-field-initializers', '-Wno-type-limits', ] - supported_warnings = cc.get_supported_arguments(all_warnings) - add_project_arguments(supported_warnings, language: 'c') -endif -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') + if get_option('debug') + mutter_c_args += [ + '-DG_ENABLE_DEBUG', + '-fno-omit-frame-pointer', + ] + endif + + supported_mutter_c_args = cc.get_supported_arguments(mutter_c_args) + add_project_arguments(supported_mutter_c_args, language: 'c') endif cc.compiles('void main (void) { __builtin_ffsl (0); __builtin_popcountl (0); }') diff --git a/mtk/meson.build b/mtk/meson.build index 6e7e347d6..76724fee8 100644 --- a/mtk/meson.build +++ b/mtk/meson.build @@ -14,17 +14,19 @@ mtk_c_args = [ ] mtk_debug_c_args = [] -if get_option('debug') - mtk_debug_c_args += [ - '-fno-omit-frame-pointer' - ] -elif buildtype != 'plain' - mtk_debug_c_args += [ - '-DG_DISABLE_ASSERT', - '-DG_DISABLE_CAST_CHECKS', - ] +if buildtype != 'plain' + if get_option('debug') + mtk_debug_c_args += [ + '-fno-omit-frame-pointer' + ] + else + mtk_debug_c_args += [ + '-DG_DISABLE_ASSERT', + '-DG_DISABLE_CAST_CHECKS', + ] + endif endif -supported_mtk_debug_c_args = cc.get_supported_arguments(mtk_debug_c_args) +mtk_debug_c_args = cc.get_supported_arguments(mtk_debug_c_args) mtk_c_args += mtk_debug_c_args mtk_pkg_deps = [