set some -Ds depending on the release type (#2682)
* set some -Ds depending on the release type libvips uses g_assert() quite a bit to check things like pointer bounds, and this can have a large performance impact. This PR turns off g_assert() (plus some other things) in release mode, and enables leak checking (and some other things) in debug mode. I'm not sure if this is the best way to implement this kind of thing. Does meson have a more offical path for this? * incorporate comments * link asserts and cast checks to optimization level
This commit is contained in:
parent
a8b48e1442
commit
4196a0e73a
19
meson.build
19
meson.build
@ -3,7 +3,9 @@ project('vips', 'c', 'cpp',
|
||||
meson_version: '>=0.56',
|
||||
default_options: [
|
||||
# this is what glib uses (one of our required deps), so we use it too
|
||||
'c_std=gnu99'
|
||||
'c_std=gnu99',
|
||||
# turn off asserts etc. in release mode
|
||||
'b_ndebug=if-release'
|
||||
]
|
||||
)
|
||||
|
||||
@ -33,6 +35,21 @@ add_project_link_arguments(
|
||||
language: 'c',
|
||||
)
|
||||
|
||||
# if we're optimising (eg. release mode) we turn off cast checks and
|
||||
# g_asserts
|
||||
if get_option('optimization') in ['2', '3', 's']
|
||||
add_project_arguments('-DG_DISABLE_CAST_CHECKS', language : ['cpp', 'c'])
|
||||
add_project_arguments('-DG_DISABLE_CHECKS', language : ['cpp', 'c'])
|
||||
add_project_arguments('-DG_DISABLE_ASSERT', language : ['cpp', 'c'])
|
||||
endif
|
||||
|
||||
# in debug mode we automatically enable leak checks and fatal warnings
|
||||
# also true for 'debugoptimized'
|
||||
if get_option('debug')
|
||||
add_project_arguments('-DDEBUG_FATAL', language : ['cpp', 'c'])
|
||||
add_project_arguments('-DDEBUG_LEAK', language : ['cpp', 'c'])
|
||||
endif
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
cpp = meson.get_compiler('cpp')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user