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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3333>
This commit is contained in:
Robert Mader 2023-10-10 04:14:51 +02:00 committed by Marge Bot
parent aaa63c1e08
commit ee65ca791b
4 changed files with 49 additions and 45 deletions

View File

@ -12,18 +12,20 @@ clutter_c_args = [
]
clutter_debug_c_args = []
if buildtype != 'plain'
if get_option('debug')
clutter_debug_c_args += [
'-DCLUTTER_ENABLE_DEBUG',
'-fno-omit-frame-pointer'
'-fno-omit-frame-pointer',
]
elif buildtype != 'plain'
else
clutter_debug_c_args += [
'-DG_DISABLE_ASSERT',
'-DG_DISABLE_CAST_CHECKS',
]
endif
supported_clutter_debug_c_args = cc.get_supported_arguments(clutter_debug_c_args)
endif
clutter_debug_c_args = cc.get_supported_arguments(clutter_debug_c_args)
clutter_c_args += clutter_debug_c_args
clutter_pkg_deps = [

View File

@ -84,20 +84,21 @@ if have_gles2
endif
cogl_debug_c_args = []
buildtype = get_option('buildtype')
if buildtype != 'plain'
if get_option('debug')
cogl_debug_c_args += [
'-DCOGL_GL_DEBUG',
'-DCOGL_OBJECT_DEBUG',
'-DCOGL_ENABLE_DEBUG',
'-fno-omit-frame-pointer'
'-fno-omit-frame-pointer',
]
elif buildtype != 'plain'
else
cogl_debug_c_args += [
'-DG_DISABLE_CAST_CHECKS'
'-DG_DISABLE_CAST_CHECKS',
]
endif
supported_cogl_debug_c_args = cc.get_supported_arguments(cogl_debug_c_args)
endif
cogl_debug_c_args = cc.get_supported_arguments(cogl_debug_c_args)
cogl_c_args += cogl_debug_c_args
subdir('cogl')

View File

@ -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 = [
mutter_c_args += [
'-DG_ENABLE_DEBUG',
'-fno-omit-frame-pointer'
'-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
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); }')

View File

@ -14,17 +14,19 @@ mtk_c_args = [
]
mtk_debug_c_args = []
if buildtype != 'plain'
if get_option('debug')
mtk_debug_c_args += [
'-fno-omit-frame-pointer'
]
elif buildtype != 'plain'
else
mtk_debug_c_args += [
'-DG_DISABLE_ASSERT',
'-DG_DISABLE_CAST_CHECKS',
]
endif
supported_mtk_debug_c_args = cc.get_supported_arguments(mtk_debug_c_args)
endif
mtk_debug_c_args = cc.get_supported_arguments(mtk_debug_c_args)
mtk_c_args += mtk_debug_c_args
mtk_pkg_deps = [