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 = [] clutter_debug_c_args = []
if get_option('debug') if buildtype != 'plain'
clutter_debug_c_args += [ if get_option('debug')
'-DCLUTTER_ENABLE_DEBUG', clutter_debug_c_args += [
'-fno-omit-frame-pointer' '-DCLUTTER_ENABLE_DEBUG',
] '-fno-omit-frame-pointer',
elif buildtype != 'plain' ]
clutter_debug_c_args += [ else
'-DG_DISABLE_ASSERT', clutter_debug_c_args += [
'-DG_DISABLE_CAST_CHECKS', '-DG_DISABLE_ASSERT',
] '-DG_DISABLE_CAST_CHECKS',
]
endif
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_c_args += clutter_debug_c_args
clutter_pkg_deps = [ clutter_pkg_deps = [

View File

@ -84,20 +84,21 @@ if have_gles2
endif endif
cogl_debug_c_args = [] cogl_debug_c_args = []
buildtype = get_option('buildtype') if buildtype != 'plain'
if get_option('debug') if get_option('debug')
cogl_debug_c_args += [ cogl_debug_c_args += [
'-DCOGL_GL_DEBUG', '-DCOGL_GL_DEBUG',
'-DCOGL_OBJECT_DEBUG', '-DCOGL_OBJECT_DEBUG',
'-DCOGL_ENABLE_DEBUG', '-DCOGL_ENABLE_DEBUG',
'-fno-omit-frame-pointer' '-fno-omit-frame-pointer',
] ]
elif buildtype != 'plain' else
cogl_debug_c_args += [ cogl_debug_c_args += [
'-DG_DISABLE_CAST_CHECKS' '-DG_DISABLE_CAST_CHECKS',
] ]
endif
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 cogl_c_args += cogl_debug_c_args
subdir('cogl') subdir('cogl')

View File

@ -466,7 +466,7 @@ add_project_arguments('-D_GNU_SOURCE', language: 'c')
buildtype = get_option('buildtype') buildtype = get_option('buildtype')
if buildtype != 'plain' if buildtype != 'plain'
all_warnings = [ mutter_c_args = [
'-fno-strict-aliasing', '-fno-strict-aliasing',
'-Wpointer-arith', '-Wpointer-arith',
'-Wmissing-declarations', '-Wmissing-declarations',
@ -506,17 +506,16 @@ if buildtype != 'plain'
'-Wno-missing-field-initializers', '-Wno-missing-field-initializers',
'-Wno-type-limits', '-Wno-type-limits',
] ]
supported_warnings = cc.get_supported_arguments(all_warnings)
add_project_arguments(supported_warnings, language: 'c')
endif
if get_option('debug') if get_option('debug')
debug_c_args = [ mutter_c_args += [
'-DG_ENABLE_DEBUG', '-DG_ENABLE_DEBUG',
'-fno-omit-frame-pointer' '-fno-omit-frame-pointer',
] ]
supported_debug_c_args = cc.get_supported_arguments(debug_c_args) endif
add_project_arguments(supported_debug_c_args, language: 'c')
supported_mutter_c_args = cc.get_supported_arguments(mutter_c_args)
add_project_arguments(supported_mutter_c_args, language: 'c')
endif endif
cc.compiles('void main (void) { __builtin_ffsl (0); __builtin_popcountl (0); }') cc.compiles('void main (void) { __builtin_ffsl (0); __builtin_popcountl (0); }')

View File

@ -14,17 +14,19 @@ mtk_c_args = [
] ]
mtk_debug_c_args = [] mtk_debug_c_args = []
if get_option('debug') if buildtype != 'plain'
mtk_debug_c_args += [ if get_option('debug')
'-fno-omit-frame-pointer' mtk_debug_c_args += [
] '-fno-omit-frame-pointer'
elif buildtype != 'plain' ]
mtk_debug_c_args += [ else
'-DG_DISABLE_ASSERT', mtk_debug_c_args += [
'-DG_DISABLE_CAST_CHECKS', '-DG_DISABLE_ASSERT',
] '-DG_DISABLE_CAST_CHECKS',
]
endif
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_c_args += mtk_debug_c_args
mtk_pkg_deps = [ mtk_pkg_deps = [