meson: Add glib_valgrind_suppressions variable to glib pkg-config file

Various projects are running tests under valgrind, and they are using
the GLib suppresions to avoid false-positive results.

While this is stored in a well-known path for some years, and easy to
figure out from the GLib prefix, it's better to expose it through a
proper pkgconfig variable so that it's easy to get it from any build
system.
This commit is contained in:
Marco Trevisan (Treviño) 2023-04-05 17:07:58 +02:00
parent 7fec23ed5e
commit fcad56e313
3 changed files with 14 additions and 6 deletions

View File

@ -441,9 +441,14 @@ pkg.generate(libglib,
subdirs : ['glib-2.0'],
extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
'datadir=' + join_paths('${prefix}', get_option('datadir')),
'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums'),
'glib_valgrind_suppressions=' + join_paths('${datadir}',
valgrind_suppression_file_install_subdir,
fs.name(valgrind_suppression_file)),
],
version : glib_version,
install_dir : glib_pkgconfigreldir,
filebase : 'glib-2.0',

View File

@ -9,6 +9,8 @@ project('glib', 'c',
]
)
fs = import('fs')
cc = meson.get_compiler('c')
c_standards = {}
@ -175,9 +177,10 @@ add_test_setup('unstable_tests',
# Allow the tests to be easily run under valgrind using --setup=valgrind
valgrind = find_program('valgrind', required: false)
if valgrind.found()
suppression_file = files('tools' / 'glib.supp')
valgrind_suppression_file = files('tools' / 'glib.supp')[0]
valgrind_suppression_file_install_subdir = 'glib-2.0' / 'valgrind'
if valgrind.found()
add_test_setup('valgrind',
exclude_suites: [ 'no-valgrind', 'flaky' ],
exe_wrapper: [
@ -191,7 +194,7 @@ if valgrind.found()
'--show-leak-kinds=definite,possible',
'--show-error-list=yes',
'--suppressions=@0@'.format(meson.project_source_root() /
'@0@'.format(suppression_file[0])),
'@0@'.format(valgrind_suppression_file)),
],
env: common_test_env,
timeout_multiplier: 20,

View File

@ -17,8 +17,8 @@ endif
if host_system != 'windows'
# Install Valgrind suppression file (except on Windows,
# as Valgrind is currently not supported on Windows)
install_data('glib.supp',
install_dir : get_option('datadir') / 'glib-2.0' / 'valgrind',
install_data(fs.name(valgrind_suppression_file),
install_dir : get_option('datadir') / valgrind_suppression_file_install_subdir,
install_tag : 'devel',
)
endif